Add F keys, DEL, sysrq

master
Cole Deck 4 years ago
parent 3c5d5fa2c0
commit 8a9e4a4464

Binary file not shown.

Binary file not shown.

@ -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)

14
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)

Loading…
Cancel
Save