I'm trying to get the PS/2 scan codes or USB usage codes of keyboard keys pressed in a Qt application. I tried overriding QWidget::keyPressEvent()
but QKeyEvent::navtiveScanCode()
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 0x26 instead of 0x1E (PS/2 Set 1) or 0x1C (Set 2 & 3) or 0x04 (USB).
This occurs even if I try to intercept the key at the X11 event loop QWidget::x11Event()
. In this case, XKeyPressedEvent::keycode
also equals to 0x26 for the 'a' key.
However, the terminal commands showkey -k
and showkey -s
both show the 'a' key to be equal to 0x1E as expected.
How do I get the PS/2 scan code or the USB usage code for key presses?
- OS: Fedora 17 x86
- X Server: 1.12.4
- X Protocol: 11 rev0
- Qt: 4.8.4