Teclado de seguimiento Presione Pynput
1 from pynput import keyboard
2
3 def on_press(key):
4 try:
5 print('Key {0} pressed'.format(key.char))
6 #Add your code to drive motor
7 except AttributeError:
8 print('Key {0} pressed'.format(key))
9 #Add Code
10 def on_release(key):
11 print('{0} released'.format(key))
12 #Add your code to stop motor
13 if key == keyboard.Key.esc:
14 # Stop listener
15 # Stop the Robot Code
16 return False
17 if key == keyboard.Key.Qkey:
18 print ("fviokbhvxfb")
19
20 # Collect events until released
21 with keyboard.Listener(
22 on_press=on_press,
23 on_release=on_release) as listener:
24 listener.join()
Fragile Frog