gdk - GTK: Check for KeyEvent including shift key -
in application, check gtk key_press event key combination <ctrl><shift><#>
.
code: (in case, python, problem language-independent, guess)
def on_key_press(self, widget, event): if ((event.keyval == gdk.key_numbersign) \ # problem , (event.state & gdk.modifiertype.shift_mask) \ , (event.state & gdk.modifiertype.control_mask)): dosomethingamazing()
the way gtk handles keypresses, actual key (for example "a") , shift key combined uppercase a. numbersign keys replaced apostrophe key on qwertz layout when shift key pressed. event.keyval combination 39 (apostrophe), not 35 (numbersign). so, <ctrl><shift><#>
need check uppercase equivalent of numbersign, instead of numbersign, might different on different keyboard layouts, cannot hard-code it.
the problem following:
>>> gdk.keyval_to_upper(35) # 35 key value numbersign 35 >>> gdk.keyval_is_upper(35) true >>> gdk.keyval_is_lower(35) true
i cannot uppercase equivalent using these functions. ideas on how fetch result of <shift><whateverkey>
combination, keyval_to_upper()
fails?
Comments
Post a Comment