It turns out there is no getch module on Linux, I found an alternative to pynput . I read the documentation, roughly understood how it works, tested it, but the question is: how do I connect with the listener , and later use the key test in a separate function that is in a loop. In a nutshell, check clicks in a while True:
from pynput import keyboard def on_press(key): try: print('alphanumeric key {0} pressed'.format( key.char)) except AttributeError: print('special key {0} pressed'.format( key)) def on_release(key): print('{0} released'.format( key)) if key == keyboard.Key.esc: # Stop listener return False # Collect events until released with keyboard.Listener( on_press=on_press, on_release=on_release) as listener: listener.join()