|
|
|
@ -1,47 +1,86 @@
|
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
from kb import write_str
|
|
|
|
|
from kb import write_special
|
|
|
|
|
from kb import write_ctrl
|
|
|
|
|
from kb import clear
|
|
|
|
|
from time import sleep
|
|
|
|
|
from getch import _Getch
|
|
|
|
|
|
|
|
|
|
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
|
|
|
arrowkey = [x for x in "ABCD"]
|
|
|
|
|
arrowout = ["UP_ARROW", "DOWN_ARROW", "RIGHT_ARROW", "LEFT_ARROW"]
|
|
|
|
|
key = [x for x in "ABCDE7890134~2"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get = _Getch();
|
|
|
|
|
while True:
|
|
|
|
|
input_key = get()
|
|
|
|
|
print(input_key + ": " + str(ord(input_key)))
|
|
|
|
|
#if input_key == "?":
|
|
|
|
|
# break
|
|
|
|
|
if ord(input_key) > 0 and ord(input_key) <= 26: # ctrl + alpha
|
|
|
|
|
idx = ord(input_key) - 1
|
|
|
|
|
letter = alpha[idx]
|
|
|
|
|
#write_special("LEFT_CTRL")
|
|
|
|
|
print("pressing CTRL + " + letter)
|
|
|
|
|
write_ctrl(letter)
|
|
|
|
|
clear()
|
|
|
|
|
continue
|
|
|
|
|
if ord(input_key) == 13:
|
|
|
|
|
write_special("ENTER")
|
|
|
|
|
clear()
|
|
|
|
|
continue
|
|
|
|
|
if ord(input_key) == 127:
|
|
|
|
|
write_special("BACKSPACE_DELETE")
|
|
|
|
|
clear()
|
|
|
|
|
continue
|
|
|
|
|
if ord(input_key) == 9:
|
|
|
|
|
write_special("TAB")
|
|
|
|
|
clear()
|
|
|
|
|
continue
|
|
|
|
|
if ord(input_key) == 27:
|
|
|
|
|
print("Special key detected!")
|
|
|
|
|
key = [x for x in "ABCDE7890134~2"]
|
|
|
|
|
#key = [x for x in "ABCDE7890134~2"]
|
|
|
|
|
input_key = get()
|
|
|
|
|
#print(ord(input_key))
|
|
|
|
|
print(input_key)
|
|
|
|
|
#if ord(input_key) == 91:
|
|
|
|
|
# input_key = get()
|
|
|
|
|
# #arrowkey = [x for x in "ABCD"]
|
|
|
|
|
# #arrowout = ["UP_ARROW", "DOWN_ARROW", "RIGHT_ARROW", "LEFT_ARROW"]
|
|
|
|
|
# write_special(arrowout[arrowkey.index(input_key)])
|
|
|
|
|
# print("pressing " + arrowout[arrowkey.index(input_key)])
|
|
|
|
|
# continue
|
|
|
|
|
if ord(input_key) == 27:
|
|
|
|
|
break
|
|
|
|
|
if input_key == "[":
|
|
|
|
|
again = False
|
|
|
|
|
input_key = get()
|
|
|
|
|
print(input_key)
|
|
|
|
|
if input_key != "[":
|
|
|
|
|
again = True
|
|
|
|
|
if input_key in arrowkey:
|
|
|
|
|
write_special(arrowout[arrowkey.index(input_key)])
|
|
|
|
|
clear()
|
|
|
|
|
print("pressing " + arrowout[arrowkey.index(input_key)])
|
|
|
|
|
continue
|
|
|
|
|
else:
|
|
|
|
|
again = True
|
|
|
|
|
input_key = get()
|
|
|
|
|
# print(input_key)
|
|
|
|
|
print(input_key)
|
|
|
|
|
num = key.index(input_key) + 1
|
|
|
|
|
if num == 13: # del
|
|
|
|
|
print("pressing DEL")
|
|
|
|
|
write_special("DELETE")
|
|
|
|
|
clear()
|
|
|
|
|
continue
|
|
|
|
|
if num == 14:
|
|
|
|
|
print("pressing prtscr / sysrq")
|
|
|
|
|
write_special("PRINT_SCREEN")
|
|
|
|
|
clear()
|
|
|
|
|
get()
|
|
|
|
|
continue
|
|
|
|
|
print("pressing F" + str(num))
|
|
|
|
|
write_special("F" + str(num))
|
|
|
|
|
clear()
|
|
|
|
|
if again:
|
|
|
|
|
get()
|
|
|
|
|
#if int(input_key) > 0 and int(input_key) <= 9:
|
|
|
|
|