Sfoglia il codice sorgente

Update 'CARDPUTER CircuitPython/keyboard.py'

cube 1 mese fa
parent
commit
4e7418e93b
1 ha cambiato i file con 7 aggiunte e 7 eliminazioni
  1. 7
    7
      CARDPUTER CircuitPython/keyboard.py

+ 7
- 7
CARDPUTER CircuitPython/keyboard.py Vedi File

@@ -23,8 +23,11 @@ class Keyboard:
23 23
             "0x4":"CTRLD", "0x13":"CTRLS", "0x9":"    ", "0x60":"ESC", "0xf":"CTRLO"
24 24
         }
25 25
 
26
-    def scan(self):
27
-        code=hex(ord(sys.stdin.read(1)))
26
+    def scan(self, keycode = None):
27
+        if not keycode:
28
+            code=hex(ord(sys.stdin.readline(1)))
29
+        else:
30
+            code = keycode
28 31
         #printing the code can be useful for debugging purposes, to check that the codes have been logged correctly if something unexpected is happening
29 32
         #print(code)
30 33
         key = None
@@ -39,13 +42,10 @@ class Keyboard:
39 42
         elif code in self.special:
40 43
             key = self.special[code]
41 44
             
42
-        if key:
43
-            return key
44
-        else:
45
-            return "UNKNOWN "+code
45
+        return key
46 46
 
47 47
     def is_alphanumeric(self, key):
48 48
         if key in self.special.values() or key in self.chars.values():
49 49
             return False
50 50
         else:
51
-            return True
51
+            return True