How to tell if a key has been released in tkinter

后端 未结 1 929
花落未央
花落未央 2021-01-20 05:35

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

相关标签:
1条回答
  • 2021-01-20 06:21

    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.

    0 讨论(0)
提交回复
热议问题