pyqtkeybind
pyqtkeybind copied to clipboard
Numpad/keypad modifier support
First of all, very nice library! I've been experimenting with it this weekend, and I'd like to use it for my new project (it's gonna be open-source, I'll post a link here after I publish it).
I'm on Ubuntu 20.04, and I've been using shortcuts like Ctrl+Shift+Space
or other with no problems at all -- but unfortunately, the numpad keys seem to not be supported at all by pyqtkeybind.
Code (e.g. add this line to your /sample/hotkey.py):
keybinder.register_hotkey(window.winId(), 'Num+0', window.close)
Result (at initialisation time):
Could not find a keycode for Num+0
And then, no reaction on pressing Numpad zero key.
In PyQt, along Qt.ShiftModifier
, Qt.ControlModifier
etc, there's a Qt.KeypadModifier
-- it's useful for catching numpad/keypad events, so keypad number keys like keypad zero etc. can be recognised separately to normal zero key. E.g., Num+0
string is definitely the string for numpad zero.
I'm not sure though on the global keystroke detection side -- is numpad problematic similarly to Win key (i.e. #7) or not... But I doubt OS would get in the way of Numpad keys ;)
I think having access to numpad keys as global shortcuts is quite useful because for those that not use those keys but still have them on the keyboard (my case here), they enable creation of nice one-keystroke shortcuts.
@mbdevpl thank you reporting this issue. I had a quick look, it appears we're not parsing the Keypad modifier here: https://github.com/codito/pyqtkeybind/blob/master/pyqtkeybind/x11/keybindutil.py#L116, below code does the parsing:
+ if (ks & Qt.KeypadModifier == Qt.KeypadModifier):
+ # mods |= ModsTbl.index(Qt.KeypadModifier)
+ qtmods |= Qt.KeypadModifier.real
+ modifiers |= getattr(xproto.KeyButMask, "Lock", 0)
Need to debug further to understand what other changes are necessary.
hello, any plan to correct the numpad modifier for windows soon? pyqtkeybind is the only stable solution for my global hotkey need in my pyqt app; however, i cannot use numpad numbers and also signs like +,-,/,* since there is a problem with the keypad modifier.
Since they are already available in QT, I believe a simple fix in keybindutil.py will solve the problem