简体   繁体   中英

How to tell if a key has been released in tkinter

I am using this code to test whether a key has been pressed, but I also need a binding that is called when a key is released. If no such binding exists, I would settle for a bit of code that continuously checks if the key is still being pressed.

w.bind("<Key>",key)

This will call onkeyrelease when any key is released:

w.bind("<KeyRelease>", onkeyrelease)

To react to a particular key's release, you would use

w.bind("<KeyRelease-key>", onkeyrelease_of_key)

where key should be replaced by the name of the key.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM