I’m trying to use the pynput library to capture key presses and releases in Python, but the listener is not responding to key events as expected. I’m running the script in a virtual environment on Arch Linux with Python 3.13.
from pynput import keyboard
def on_press(key):
print(f'{key} pressed')
def on_release(key):
print(f'{key} released')
if key == keyboard.Key.esc:
return False # Stop listener when Esc is pressed
#Start the listener
with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
listener.join()
lang-py
pynputin Python 3.13.not responding to key events as expected? I doesn't work as all? or it doesn't work with some keys? Or it work in slow or something else? We can't see your computer, we can't read in your mind - you have to describe all details in question (not in comments)rootbecause it need access to some/dev/.... Probably it can be changed with some settings. (Platform limitations — pynput 1.7.6 documentation). But modules like keyboard ormousedon't have this problem