I have a Python program that involves checking if a key (and which key) is pressed on the keyboard. I use the Python library "pynput". The following minimum code example runs perfectly fine on my raspy 5 with the Thonny IDE and also with the PyCharm IDE. But unfortunately it does not work with the Geany IDE. Pressed keys are just not detected under Geany. Can anyone give me a hint, how I can solve this.
Here is my code example:
Here is my code example:
Code:
from pynput import keyboarddef on_press(key): try: print('alphanumeric key {0} pressed'.format( key.char)) except AttributeError: print('special key {0} pressed'.format( key))def on_release(key): print('{0} released'.format( key)) if key == keyboard.Key.esc: # Stop listener return Falselistener = keyboard.Listener( on_press=on_press, on_release=on_release)listener.start()
Statistics: Posted by OliEwald — Fri Jan 17, 2025 6:34 pm — Replies 1 — Views 17