Check if keyboard key is down
-
Is there an easy way to simply test if a keyboard key is down? I am in a mouse event and want to know if the ctrl key is down for example.
Thanks.
-
Those are two different things.
The mouse event delivers "modifiers":http://doc.qt.nokia.com/latest/qinputevent.html#modifiers , which are "Ctrl, shift etc.":http://doc.qt.nokia.com/latest/qt.html#KeyboardModifier-enum
For other keys, you have to use OS specific things. -
... or listen for key events and store them someplace. I did not realize the mouse event had modifiers, in this case it looks like I am covered.
Thanks again. :)
-
[quote author="mirswith" date="1316037198"]... or listen for key events and store them someplace.[/quote]
This will not work 100%. Think of someone put's the focus out of your app, presses shift and then click into your app. You would not get the shift press as key event...
-
Makes sense. Sounds like we need a new class with the static call, QKeyboard::isKeyDown(int key); I noticed there is a gaming forum here, what is being recommended for games since they will need something along these lines?