ModifierKeys (ctrl/shift/alt) not working


#1

Windows 7, 64 bit.

In juce_win32_Windowing.cpp, isKeyDown() never returns true. For some reason, GetAsyncKeyState always returns 0. Switching it to GetKeyState fixed it.

Mike


#2

But GetKeyState doesn’t pick up keypresses that occur between message dispatching, which is why I specifically chose to use GetKeyStateAsync.

I can’t see any reason why it would fail… Are you perhaps trying to call it from a thread other than the message thread?


#3

No. It happens with the JuceDemo as well. None of the hotkeys are picked up (ctrl + 1 , ctrl + 2, etc).

I have no idea why it wouldn’t be working either.


#4

Just tried it with the demo myself in Win7 and it seems fine… I tried

if (KeyPress ('a', ModifierKeys::ctrlModifier, 0).isCurrentlyDown()) { ..draw a blob

…in a paint method and it worked perfectly well.

Maybe explain what you’re trying to do that fails?


#5

I was trying to see if Ctrl was pressed. isCtrlDown() was returning false. Then I checked shift and alt as well.

Then I tried the hotkeys associated with menu commands. Ctrl-c, ctrl-v, etc. They also did not work. Then I thought it might be something with my program so I tried JuceDemo and its hotkeys didn’t work either.

I’m on Windows 7 64 bit compiling a 32 bit program.


#6

Well the hotkeys work for me, and since almost everyone probably uses ctrl shortcuts, I’d have expected a lot of people to be complaining if they didn’t work!

I’m a bit stumped as to why you’d be having problems though. Is your Windows setup a bit strange in any way? Do other programs work ok!?


#7

[quote=“bikemike”]In juce_win32_Windowing.cpp, isKeyDown() never returns true. For some reason, GetAsyncKeyState always returns 0. Switching it to GetKeyState fixed it.
[/quote]

How did you determine that you were getting 0? The big difference between the two is that GetKeyState is the virtual state of the keyboard. The state of the keyboard based on messages already dispatched with getmessage or peekmessage. GetAsyncState is the actual current state of the keyboard (well, almost, it is the master virtual key table). It is hard to imagine how GetAsyncState would be not working while GetKeyState worked.