Update 'CARDPUTER CircuitPython/keyboard.py'
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user