def keyNameToKeyCode(keyName):
"""
Use GDK to get the keycode for a given keystring.
Note that the keycode returned by this function is often incorrect when
the requested keystring is obtained by holding down the Shift key.
Generally you should use uniCharToKeySym() and should only need this
function for nonprintable keys anyway.
"""
keymap = Gdk.Keymap.get_for_display(Gdk.Display.get_default())
entries = keymap.get_entries_for_keyval(
Gdk.keyval_from_name(keyName))
try:
return entries[1][0].keycode
except TypeError:
pass
评论列表
文章目录