Cross platform/region keyboard input?

Monkey Forums/Monkey Programming/Cross platform/region keyboard input?

Skn3(Posted 2013) [#1]
I am looking into some text input at the moment and have noticed that in glfw (and probably other targets) there is not a reliable way to get correct keyboard input?

If I use keyhit and keydown I would be getting raw keycodes and I don't currently see a way for converting that to the users keyboard layout ASCII value. There are also limitations in that not all keys are supported such as the numpad or alt keys.

I can use getchar but this doesn't properly support Ctrl key so if I wanted to check for Ctrl + something I would be forced to use keyhit, but as described above...

Maybe I'm missing something but how have other people tackled this? It's a little bit limiting if you cant properly support multi layout keyboards...


Skn3(Posted 2013) [#2]
None else had problems with monkeys input? Not being able to access the numpad or distinguish between L/R shift/control or missing keys? Hmmm...

Well anyway I spent a bit of time writing some code.

https://bitbucket.org/skn3/monkeymodules/src/master/skn3/keyboardex/keyboardex.monkey

It is for GLFW only but basically you call UpdateKeyboard() every update loop and it will cache all keyboard states including key ticks. It does this using a direct glfw call instead of monkeys internal cache.

You can then access the states with KeyboardPressed() and KeyboardHeld().

I decided not to use the code for now, but someone might have some use for it.

If you look here:
https://bitbucket.org/skn3/monkeymodules/src/master/skn3/keyboardex/native/keyboardex.glfw.cpp

...there is also code example for changing one of the glfw key callbacks. The code replaces monkeys internal charcallback (the one used by monkey in order to make GetChar() work). I don't know if it is any use for anyone but I am sure someone might find some value for it in the future.