From 4e7418e93b4f2a3ec8613cf960412bdaf44840e1 Mon Sep 17 00:00:00 2001 From: cube Date: Thu, 5 Feb 2026 22:42:14 +0000 Subject: [PATCH] Update 'CARDPUTER CircuitPython/keyboard.py' --- CARDPUTER CircuitPython/keyboard.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CARDPUTER CircuitPython/keyboard.py b/CARDPUTER CircuitPython/keyboard.py index e28490e..19f30ea 100644 --- a/CARDPUTER CircuitPython/keyboard.py +++ b/CARDPUTER CircuitPython/keyboard.py @@ -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 \ No newline at end of file + return True