-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeyboard.py
40 lines (34 loc) · 895 Bytes
/
keyboard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import keyboard
import time
with open('keyboard_commands.txt', 'w') as f:
f.write('n')
while True:
command = raw_input("Enter command: ")
if command == 's':
print("stopping robot")
with open('keyboard_commands.txt', 'w') as f:
f.write('s')
elif command == 'e':
print("ending task")
with open('keyboard_commands.txt', 'w') as f:
f.write('e')
else:
with open('keyboard_commands.txt', 'w') as f:
f.write('n')
time.sleep(5)
with open('keyboard_commands.txt', 'w') as f:
f.write('n')
'''
space = False
def space_pressed():
global space
print('pressed')
space = True
keyboard.add_hotkey('space', space_pressed)
while True:
print(space)
if space == True:
with open('keyboard_commands.txt', 'w') as f:
f.write('s')
space = False
'''