I'm looking for a simple way to detect a keypress inside a loop without importing something like pygame, something along the lines of
pressed('a') #returns True if key 'a' pressed, False otherwise
I'm aware of this Keypress detection thread, but unfortunately when I run the recommended code or try anything using keyboard.is_pressed(), I get
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\myname\AppData\Local\Programs\Python\Python37\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\Users\myname\AppData\Local\Programs\Python\Python37\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\myname\AppData\Roaming\Python\Python37\site-packages\keyboard\__init__.py", line 292, in listen
_os_keyboard.listen(self.direct_callback)
File "C:\Users\myname\AppData\Roaming\Python\Python37\site-packages\keyboard\_winkeyboard.py", line 560, in listen
prepare_intercept(callback)
File "C:\Users\myname\AppData\Roaming\Python\Python37\site-packages\keyboard\_winkeyboard.py", line 553, in prepare_intercept
keyboard_hook = SetWindowsHookEx(WH_KEYBOARD_LL, keyboard_callback, GetModuleHandleW(NULL), NULL)
ctypes.ArgumentError: argument 3: <class 'OverflowError'>: int too long to convert
(Pretty new to Python, so not sure what any of the above means)
keyboard.is_pressed() is my ideal solution, but I'm completely open to other equally simple ones too.