Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
share|improve this question
1  
I don't think this is possible. You get the X keysym and the X keycode, I don't think X is interested in reporting whatever values the hardware may have used to keep track of the key. – Gilles Jan 21 at 21:51

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.