Keyboard input/Keypress check: Difference between revisions

Content added Content deleted
Line 479: Line 479:
while True:
while True:
if char is not None:
if char is not None:
print("Key pressed is " + char.decode('utf-8'))
try:
print("Key pressed is " + char.decode('utf-8'))
except UnicodeDecodeError:
print("character can not be decoded, sorry!")
char = None
_thread.start_new_thread(keypress, ())
_thread.start_new_thread(keypress, ())
if char == 'q' or char == '\x1b': # x1b is ESC
if char == 'q' or char == '\x1b': # x1b is ESC