Keyboard Key without modifier



  • Hi,

    I'm looking for a portable and reliable way to get key input ignoring any modifiers, for example on a UK keyboard '!' is assigned to the '1' key when shift is down.

    What I need is to be able to convert '!' when the shift key is down to whatever the key should be without it. I could simply hard code '!' = '1' but obviously this won't work for foreign keyboards which have different placements.

    I found the function nativeScanCode in QKeyEvent but it clearly states that this will always return 0 on Mac OS/X making this useless.

    Appreciate any help with this!


  • Moderators

    Hi! You could install a key event filter on your object (or maybe on the QApplication object). In that event filter you'd catch all key press events that have a modifier, remove the modifier from such an event and then proceed the event handling with the altered event.

    As a starting point, have a look at this post.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.