Hello,
I’m trying to get the PS/2 scan codes or USB usage codes of keyboard keys pressed in a Qt application running on Linux. I tried overriding QWidget::keyPressEvent() [qt-project.org] but QKeyEvent::navtiveScanCode() [qt-project.org] returns a value which doesn’t correspond to the key’s equilvalent PS/2 Set 1, Set 2, or Set 3 scan code nor the USB usage code. Instead, I believe this function returns a X11 mapped keycode.
Example: the ‘a’ key returns 0×26 instead of 0×1E (PS/2 Set 1) or 0×1C (Set 2 & 3) or 0×04 (USB).
This occurs even if I try to intercept the key at the X11 event loop QWidget::x11Event( [qt-project.org]). In this case, XKeyPressedEvent::keycode [x.org] also equals to 0×26 for the ‘a’ key.
However, the terminal commands showkey -k [linux.die.net] and showkey -s [linux.die.net] both show the ‘a’ key to be equal to 0×1E as expected.
How do I get the PS/2 scan code or the USB usage code for key presses?
OS: Fedora 17 ×86
X Server: 1.12.4
X Protocol: 11 rev0
Qt: 4.8.4
Regards,
Daniel K.
↧