Reputation: 1827
I am using
QShortcut* capsKey = new QShortcut (Qt::Key_CapsLock, this, SLOT(keyCaps() ));
However, the signal is only detected every other time, when capslock is engaged (caps lock led turned on) - not when it is disabled (caps lock led turned off)
How do I detect also the other key? Thanks
[I'm using Qt5.4 on a 2014 macbook pro]
Upvotes: 2
Views: 684
Reputation: 32742
The caps lock key can be funny. I don't know exactly what's going on, but can make a few guesses.
On some early Mac keyboards, the caps lock key physically locked down when pressed, so the a release code would not be generated until the key was hit a second time. Later key handlers for keyboards that don't have a physical lock may emulate that same behavior (so that older apps that were expecting it would still work). What your program would get would be a press, then later a release when the lock key is hit a second time. If that's the case, there is only one key press to detect, and not two.
Some platforms allow the user to turn off caps lock without hitting the caps lock key (typically by hitting the shift key). In those systems there might not be a second hit at all.
Upvotes: 2