forked from abhisheknaik96/MultiAgentTORCS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_keyboard.py
More file actions
44 lines (35 loc) · 778 Bytes
/
get_keyboard.py
File metadata and controls
44 lines (35 loc) · 778 Bytes
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
41
42
43
44
import time
import pyxhook
up = False
down = False
left = False
right = False
def kbup(event):
global up, down, left, right
if event.Ascii == 81:
left = True
elif event.Ascii == 82:
up = True
elif event.Ascii == 83:
right = True
elif event.Ascii == 84:
down = True
def kbdown(event):
global up, down, left, right
if event.Ascii == 81:
left = False
elif event.Ascii == 82:
up = False
elif event.Ascii == 83:
right = False
elif event.Ascii == 84:
down = False
def main():
hookman = pyxhook.HookManager()
hookman.KeyDown = kbup
hookman.KeyUp = kbdown
hookman.HookKeyboard()
hookman.start()
hookman.cancel()
if __name__ == "__main__":
main()