How can I detect key release with python 3 ?
Like if I pressed the key a for 1 second , when I remove my finger from the key ( releasing the key ) , It will print("Key 'a' pressed then released").
I trying to do it with module keyboard but I have no idea about how to use it for this. I used to detect keypress with it.
msvcrt module don't work for me but if msvcrt can do what I want , then you can answer me.
Note:
I Don't want to use Pygame or any other module which will show pop-ups
You can use the
pynputmodule:According to the documentation of
pynputkeyboard listener is a thread, which calls the function specified onon_releasewith the key argument. You can also specify aon_pressfunction.Edit:
As asked in discussions, you can stop the listener by returning
falsefrom theon_key_releasefunction. Like that: