-
Notifications
You must be signed in to change notification settings - Fork 7
/
get_key.py
549 lines (331 loc) · 5.76 KB
/
get_key.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
# coding=utf-8
def shift_command():
# return 225
return 0
def command_command():
# return 227
return 0
def control_command():
# return 224
return 0
def alt_command():
# return 226
return 0
def escape_command():
return 41
def function_command():
return 0
def singlequote():
return 52
def exclamation():
return 30
def doublequote():
return 52
def bang():
return 32
def dollar():
return 33
def percent():
return 196
def ampersand():
return 199
def left_bracket():
return 47
def right_bracket():
return 48
def plus():
return 87
def comma():
return 54
def minus():
return 45
def underscore():
return 45
def period():
return 55
def forward_slash():
return 56
def zero():
return 39
def one():
return 30
def two():
return 31
def three():
return 32
def four():
return 33
def five():
return 34
def six():
return 35
def seven():
return 36
def eight():
return 37
def nine():
return 38
def colon():
return 203
def semicolon():
return 51
def less_than():
return 197
def equals_to():
return 103
def more_than():
return 198
def questionmark():
return 56
def at_symbol():
return 206
def open_square_bracket():
return 47
def backward_slash():
return 49
def close_square_bracket():
return 48
def power_of():
return 35
def backtick():
return 53
def backspace():
return 42
def letter_a():
return 4
def letter_b():
return 5
def letter_c():
return 6
def letter_d():
return 7
def delete_char():
return 76
def down():
return 81
def letter_e():
return 8
def enter_char():
return 40
def letter_f():
return 9
def function_one():
return 58
def function_ten():
return 67
def function_eleven():
return 68
def function_twelve():
return 69
def function_two():
return 59
def function_three():
return 60
def function_four():
return 61
def function_five():
return 62
def function_six():
return 63
def function_seven():
return 64
def function_eight():
return 65
def function_nine():
return 66
def free_button():
return 4
def letter_g():
return 10
def letter_h():
return 11
def letter_i():
return 12
def letter_j():
return 13
def letter_k():
return 14
def letter_l():
return 15
def left():
return 80
def letter_m():
return 16
def letter_n():
return 17
def letter_o():
return 18
def letter_p():
return 19
def null_key():
return 0
def letter_q():
return 20
def letter_r():
return 21
def right():
return 79
def letter_s():
return 22
def space_char():
return 44
def letter_t():
return 23
def tab_char():
return 43
def letter_u():
return 24
def up():
return 82
def letter_v():
return 25
def letter_w():
return 26
def letter_x():
return 27
def letter_y():
return 28
def letter_z():
return 29
def open_squigly_bracket():
return 47
def bar():
return 201
def close_squigly_bracket():
return 48
def tilde():
return 53
def pound():
return 204
def euro():
return 4
def home():
return 74
def end():
return 77
def pgup():
return 75
def pgdown():
return 78
def volup():
return 128
def voldown():
return 129
def mute():
return 127
def power_button():
return 161
def dim():
return 102
def brighten():
return 0
lookup = {
'0': zero,
'1': one,
'2': two,
'3': three,
'4': four,
'5': five,
'6': six,
'7': seven,
'8': eight,
'9': nine,
'a': letter_a,
'b': letter_b,
'c': letter_c,
'd': letter_d,
'e': letter_e,
'f': letter_f,
'g': letter_g,
'h': letter_h,
'i': letter_i,
'j': letter_j,
'k': letter_k,
'l': letter_l,
'm': letter_m,
'n': letter_n,
'o': letter_o,
'p': letter_p,
'q': letter_q,
'r': letter_r,
's': letter_s,
't': letter_t,
'u': letter_u,
'v': letter_v,
'w': letter_w,
'x': letter_x,
'y': letter_y,
'z': letter_z,
'Alt': alt_command,
'Backspace': backspace,
'Command': command_command,
'Ctrl': control_command,
'Del': delete_char,
'Down': down,
'Enter': enter_char,
'Esc': escape_command,
'F1': function_one,
'F10': function_ten,
'F11': function_eleven,
'F12': function_twelve,
'F2': function_two,
'F3': function_three,
'F4': function_four,
'F5': function_five,
'F6': function_six,
'F7': function_seven,
'F8': function_eight,
'F9': function_nine,
'Fn': function_command,
'Free1': free_button,
'Left': left,
'phantom': null_key,
'Right': right,
'Shift': shift_command,
'Space': space_char,
'Tab': tab_char,
'Up': up,
'Home': home,
'End': end,
'PgUp': pgup,
'PgDown': pgdown,
'VolUp': volup,
'VolDown': voldown,
'Mute': mute,
'Power': power_button,
'Dim': dim,
'Brighten': brighten,
'{': open_squigly_bracket,
'|': bar,
'}': close_squigly_bracket,
'~': tilde,
'£': pound,
'€': euro,
"'": singlequote,
'!': exclamation,
'"': doublequote,
'#': bang,
'$': dollar,
'%': percent,
'&': ampersand,
'(': left_bracket,
')': right_bracket,
'+': plus,
',': comma,
'-': minus,
'_': underscore,
'.': period,
'/': forward_slash,
':': colon,
';': semicolon,
'<': less_than,
'equals': equals_to,
'>': more_than,
'?': questionmark,
'@': at_symbol,
'[': open_square_bracket,
'backslash': backward_slash,
']': close_square_bracket,
'^': power_of,
'`': backtick
}