Hello i am wondering if there is a way to check if a certain key is being held down.
Here is an example of the situation
self.button2.Bind(wx.EVT_LEFT_DOWN, self.clickedbutton)
def clickedbutton(self, e):
if (Control is held down while the button has been clicked):
print "it works"
Thanks
The problem with using only wx for this is that you need a KeyEvent to access the actual state of the control key. Since you need this information outside of such an event you need to keep track of it manually, and the problem with that is that it is easy to miss a KeyEvent since only focused controls get them and you can’t count on them propagating.
The foolproof way would be to utilize some platform specific way of querying this information, if you are on windows look in to pyHook or win32api for this.
In some cases though the wx only approach can work and here is how you do it: