I noticed the numbers associated with keycodes differ from operating systems.
http://www.wxpython.org/docs/api/wx.KeyEvent-class.html
For example on my Mac wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE are 127 and 385 respectively.
On Windows wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE are 13 and 370 respectively
Do the values associated with these variables vary only between platform or also OS version and keyboard?
Also I’m trying to detect the keydown of the “delete” button on my macbook’s keyboard.
self.fileOlv = FastObjectListViewEdit(panel, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
self.fileOlv.Bind(wx.EVT_KEY_DOWN, self.printCode)
def printCode(self,evt):
print evt.GetKeyCode()
Pressing “delete” prints 8
Pressing “fn” prints 0
Pressing “delete” + “fn” prints 127
127 corresponds to the value of wx.WXK_DELETE on my Mac, but I could not find any keycode that corresponded to 8. Are there any keycodes that corresponde to pressing the “delete” key on a mac in http://www.wxpython.org/docs/api/wx.KeyEvent-class.html ?
Is there a way I can detect the “delete” key being pressed down without someone having to simultaneously press the “fn” key? I’m concerned if I bind my handler to the evt.GetKeyCode() of 8 on a Mac, that on different types of Macs the value of evt.GetKeyCode() would vary.
What is the best approach to detect events not in the keycode table?
I also wanted to add that for some reason pressing the “delete” key prints 127 instead of 8, as opposed to my above code, when I use this code snippet
import sys
import tty
tty.setcbreak(sys.stdin)
while True:
print ord(sys.stdin.read(1))