KeyDown() / KeyHit() issue.
Monkey Forums/Monkey Bug Reports/KeyDown() / KeyHit() issue.| 
 | ||
| KeyDown(KEY_Z) does not work with german keyboard layout. I have to press 'Y' key in Mojo2 demo 'shadereffect.monkey', Glfw3 target. 'If GetChar = 122' works. | 
| 
 | ||
| According to glfw docs, the US keyboard layout is used: http://www.glfw.org/docs/latest/group__keys.html Im not sure there's much I can do about this - I don't have access to foreign keyboards (or the knowledge to use them) and even if I did, I don't know how I'd come up with all the necessary translation tables, which I imagine would be a seriously mammoth task... Perhaps there's a glfw utility out there that does this? Any other ideas? | 
| 
 | ||
| Ugh, sounds like it's a new 'feature' in glfw3... https://github.com/glfw/glfw/issues/114 The fix appears to be a new function that converts the keycode to unicode, at which point I guess I have to turn it back into a keycode - funtime! | 
| 
 | ||
| Is this new to glfw3? Did it happen in glfw2? | 
| 
 | ||
| Thanks, I guess it is better to avoid KeyDown() for alphabet characters. The following works fine: Method OnUpdate()
    Local char:= GetChar()
    If char = "a"[0] Or char = "A"[0]       ' KeyDown( KEY_A )
        level = Min(level + 0.01, 1.0)
    Else If char = "z"[0] Or char = "Z"[0]  ' KeyDown( KEY_Z )
        level = Max(level - 0.01, 0.0)
    EndIf
Endor Method OnUpdate()
    Select GetChar()
        Case "a"[0], "A"[0]                 ' KeyDown( KEY_A )
            level = Min(level + 0.01, 1.0)
        Case "z"[0], "Z"[0]                 ' KeyDown( KEY_Z )
            level = Max(level - 0.01, 0.0)
    End Select 'note: EndSelect not allowed
End | 
| 
 | ||
| Can you confirm this is new to glfw3 though? It's mighty inconvenient! How do you write instructions? | 
| 
 | ||
| With Glfw2 KeyHit(KEY_Z) works with german keyboard 'z' key, so this has changed with Glfw3. | 
| 
 | ||
| On Windows? | 
| 
 | ||
| Yes, Windows 8.1 Just used the breakout example with Glfw2 target (MonkeyX 0.83c) and changed the 'reset level' KeyHit(KEY_R) to KeyHit(KEY_Z) and KeyHit(KEY_Y). Both work correctly with Glfw2 (on german kbd layout Y and Z are exchanged). Same test with Glfw3 target (0.83c and 0.84a), the keys don't work correctly. Have to press Y key for KeyHit(KEY_Z) check. Have to press Z key for KeyHit(KEY_Y) check. |