import keyboard while True: try: if keyboard.is_pressed('q'): print('You Pressed the Q Key!') elif keyboard.is_pressed('a'): print('You Pressed the A key!') break except: break