diff --git a/__pycache__/getch.cpython-37.pyc b/__pycache__/getch.cpython-37.pyc index f0ed174..020da56 100644 Binary files a/__pycache__/getch.cpython-37.pyc and b/__pycache__/getch.cpython-37.pyc differ diff --git a/__pycache__/kb.cpython-37.pyc b/__pycache__/kb.cpython-37.pyc index 570b36d..809b832 100644 Binary files a/__pycache__/kb.cpython-37.pyc and b/__pycache__/kb.cpython-37.pyc differ diff --git a/input.py b/input.py index 4c57a36..268002f 100755 --- a/input.py +++ b/input.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 from kb import write_str +from kb import write_special from time import sleep from getch import _Getch @@ -7,8 +8,39 @@ get = _Getch(); while True: input_key = get() print(input_key) - #if input_key == "?": - # break - if ord(input_key) == 27: + if input_key == "?": break + if ord(input_key) == 27: + print("Special key detected!") + key = [x for x in "ABCDE7890134~2"] + if get() == "[": + again = False + input_key = get() + if input_key != "[": + again = True + input_key = get() + # print(input_key) + num = key.index(input_key) + 1 + if num == 13: # del + print("pressing DEL") + write_special("DELETE") + continue + if num == 14: + print("pressing prtscr / sysrq") + write_special("PRINT_SCREEN") + continue + print("pressing F" + str(num)) + write_special("F" + str(num)) + if again: + get() + #if int(input_key) > 0 and int(input_key) <= 9: + # write_special("F" + input_key) + #if input_key == "0": + # write_special("F10") + #if input_key == "-": + # write_special("F11") + #if input_key == "=": + # write_special("F12") + #if ord(input_key) == 27: + # break write_str(input_key) diff --git a/kb.py b/kb.py index 8c1f65d..27fb08c 100755 --- a/kb.py +++ b/kb.py @@ -48,6 +48,9 @@ def write_caps(char): write_report(chr(32)+NULL_CHAR+chr(char)+NULL_CHAR*5) def write_str(word): for letter in word: + if letter == "~": + letter = "`" + write_caps(keycodes.keycodelst[letter]) if letter == "|": letter = "\\" write_caps(keycodes.keycodelst[letter]) @@ -55,9 +58,11 @@ def write_str(word): if letter == "!": letter = "1" write_caps(keycodes.keycodelst[letter]) + continue if letter == "*": letter = "8" write_caps(keycodes.keycodelst[letter]) + continue if letter.capitalize() == letter and letter >= 'A' and letter <= 'Z': #print(letter.capitalize(), letter) write_caps(keycodes.keycodelst[letter]) @@ -74,6 +79,15 @@ def write_str(word): finally: write_report(NULL_CHAR*8) +def write_special(input): + #lst = [x for x in input] + #if lst[0] == "F": # F key requested! + try: + write_char(keycodes.keycodelst[input]) + except: + print("Unsupported keycode! Ask Cole Deck to add support.") + finally: + write_report(NULL_CHAR*8) #write_str("root\n") #time.sleep(0.5)