Browse Source

check if key pressed is alphanumeric

also happens to ignore unknown key presses
cube 9 months ago
parent
commit
19d0950145
1 changed files with 8 additions and 2 deletions
  1. 8
    2
      CARDPUTER CircuitPython/keyboard.py

+ 8
- 2
CARDPUTER CircuitPython/keyboard.py View File

@@ -20,7 +20,7 @@ class Keyboard:
20 20
         }
21 21
         self.special={
22 22
             "0xa":"\n", "0x8":"BACKSP", "0x20":" ", "0x3b":"UP", "0x2e":"DOWN", "0x2c":"LEFT", "0x2f":"RIGHT", "0x10d":"OPTD",
23
-            "0x4":"CTRLD", "0x13":"CTRLS", "0x9":"    ", "0x60":"ESC"
23
+            "0x4":"CTRLD", "0x13":"CTRLS", "0x9":"    ", "0x60":"ESC", "0xf":"CTRLO"
24 24
         }
25 25
 
26 26
     def scan(self):
@@ -42,4 +42,10 @@ class Keyboard:
42 42
         if key:
43 43
             return key
44 44
         else:
45
-            return "UNKNOWN "+code
45
+            return "UNKNOWN "+code
46
+
47
+    def is_alphanumeric(self, key):
48
+        if key in self.special.values() or key in self.chars.values():
49
+            return False
50
+        else:
51
+            return True