I am using Python2 on Ubuntu, and I would like to write a loop which waits for either (i) a particular key to be pressed, or (ii) another function to return True.
For example:
while not (check_key() == 'n' or foo() == True):
continue
The problem is, all solutions I can find for the check_key() function are blocking: they wait until a key is pressed before returning. This means that my foo() function will never be evaluated.
Are there any solutions for check_key() which will check whether a key is currently being pressed, and if so, return the value of that key, but otherwise will return nothing and allow foo() to be evaluated?