Update 'CARDPUTER CircuitPython/keyboard.py'

This commit is contained in:
2026-02-05 22:42:14 +00:00
parent bf4780dcea
commit 4e7418e93b

View File

@@ -23,8 +23,11 @@ class Keyboard:
"0x4":"CTRLD", "0x13":"CTRLS", "0x9":" ", "0x60":"ESC", "0xf":"CTRLO"
}
def scan(self):
code=hex(ord(sys.stdin.read(1)))
def scan(self, keycode = None):
if not keycode:
code=hex(ord(sys.stdin.readline(1)))
else:
code = keycode
#printing the code can be useful for debugging purposes, to check that the codes have been logged correctly if something unexpected is happening
#print(code)
key = None
@@ -39,13 +42,10 @@ class Keyboard:
elif code in self.special:
key = self.special[code]
if key:
return key
else:
return "UNKNOWN "+code
return key
def is_alphanumeric(self, key):
if key in self.special.values() or key in self.chars.values():
return False
else:
return True
return True