from pynput.keyboard import Key, Controller keyboard = Controller() while True: if keyboard.press('space'): print ('You Pressed A Key!')