如何判断密钥是否已在Tkinter中释放 [英] How to tell if a key has been released in tkinter
本文介绍了如何判断密钥是否已在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)
推荐答案
当释放任何键时,它将调用onkeyrelease
:
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)
其中key
应替换为键的名称.
where key
should be replaced by the name of the key.
这篇关于如何判断密钥是否已在Tkinter中释放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文