import keyboard import time while True: if keyboard.is_pressed('w'): print('Forward') elif keyboard.is_pressed('s'): print('Backward') elif keyboard.is_pressed('a'): print('Left') elif keyboard.is_pressed('d'): print('Right') elif keyboard.is_pressed('enter'): # if key 'enter' is pressed print('You pressed enter!') elif keyboard.is_pressed('q'): print('Quit!') break time.sleep(0.1)
标签:输出,elif,enter,键盘输入,跟据,pressed,keyboard,print From: https://www.cnblogs.com/daizichuan/p/17488943.html