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.
Python minimum code example:
`from pynput import keyboard`
`def 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:` ` return False`
`listener = keyboard.Listener(` ` on_press=on_press,` ` on_release=on_release)` `listener.start()`
How exactly do you run this code in Geany?
And how does this code run at all? When I execute it in a terminal, it doesn't listen at all, just exits immediately.
You are right, it does not run in Terminal (though I do not yet why - still investigating). In Thonny IDE (on Raspberry Pi 5) it works perfectly. If I do the same in Geany IDE it does not run (it just terminates withvexit code 0; Same as in Terminal).
Closed #4207 as completed.
I just found out, that the problem is related to the Display Server Protocol "Wayland" (and not to Geany). If I switch from Wayland to to X11, everything works fine.
github-comments@lists.geany.org