Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
qkeyevent Ignore modifiers
Megamouse last edited by Megamouse
How can i ignore modifiers and only show the actual key that was pressed?
E.g. I don't want to get the key for ( when I press shift+8 on a german layout. I want the key for 8.
edit: It would also be okay if I could simply disable the modifiers completely
@Megamouse Why don't you simply check http://doc.qt.io/qt-5/qkeyevent.html#modifiers? See http://doc.qt.io/qt-5/qt.html#KeyboardModifier-enum
@jsulm I'm sorry but this isn't helpful at all
If you want to just know which key is pressed, look at http://doc.qt.io/qt-5/qkeyevent.html#key member function. Unlike http://doc.qt.io/qt-5/qkeyevent.html#text, the former gives the raw key, without applying modifiers to generate the corresponding Unicode character.
@JonB key() returns different codes for let's say... 1 and shift+1 (namely ! on german keyboards).
but I need the same value regardless of the shift
@JonB Key_1 and Key_Exclam
@Megamouse That's a bit of a blow, then! :(
JonB last edited by JonB
Then I think you'll have to go down to the level of http://doc.qt.io/qt-5/qkeyevent.html#nativeScanCode
Don't ask me where you look up its return values though, as I don't know that!
And if that doesn't work, and you/I don't see another method to get at raw keyboard keys, I can only see that you'll have to write a large
QKeyEvent::key()for your keyboard!