I’ve ran into an issue of Component::keyPressed(const juce::KeyPress& key) not representing the button down states (keycodes and character codes) the same way as when querying them using KeyPress::isKeyCurrentlyDown(const int keyCode).
I’m calling isKeyCurrentlyDown() from Component::keyStateChanged(bool isKeyDown).
Here is what I get when pressing “q”, which gives the correct output which I expect to see:
keycode: 81, character code: 113 == 'q' ---> Output from keyPressed(const juce::KeyPress& key)
keycode: 81 ---> Output from isKeyCurrentlyDown()
keycode: 113 ---> Also output at the same time from the same isKeyCurrentlyDown()
So two different keycodes respond to being pressed down when I go through all of them.
In this case the outputs match between keyPressed() and isKeyCurrentlyDown().
Here is what I get when pressing “ü” which gives wrong output which needs to be fixed somehow:
keycode: 252, character code: 252 == 'ü' ---> Output from keyPressed(const juce::KeyPress& key)
keycode: 58 ---> Output from isKeyCurrentlyDown()
keycode: 59 ---> Also output at the same time from isKeyCurrentlyDown()
keycode: 186 ---> Also output at the same time from isKeyCurrentlyDown()
So when I press “ü”, I get three keycodes telling me that they are held down. None of them match with what the keyPressed() says about being pressed down. keyPressed() seems to return the correct keycodes though.
So what is going on and how to fix this issue so that isKeyCurrentlyDown() also returns matching keycodes when I poll through the full keycode range with that method?
What I’m trying to do is to ensure my keyboard layout localization works properly. I’m using Windows/Finnish keyboard with German keyboard layout turned on in Windows to test that everything works as they should. I don’t know if this affects the results or not.
EDIT:
This seems to be happening also when I have my finnish scandic keyboard and windows is set for that keyboard layout. When pressing scandic letter keys, they are not recognized by isKeyCurrentlyDown() when called from keyStateChanged().
This what comes out of keyPressed() when I press “ä”:
keycode: 228, character code: 228 == ‘ä’
And this is what isKeyCurrentlyDown() reports to me:
keycode: 222
My personal diagnosis is that somehow JUCE doesn’t report scandic letters properly when using keyStateChanged() polling. Can anyone confirm this is the real issue? How to fix this so that both methods can be used to get keypresses regarding same scandic keys?