exe's picture

Unicode keyboard input in GameWindow

How to read unicode keyboard input?

I'm currently using OpenTK.Input.KeyboardKeyEventArgs (Keyboard.KeyDown event), and manual key-to-char conversion:

if (key == OpenTK.Input.Key.Q) { c += "q"; }
if (key == OpenTK.Input.Key.W) { c += "w"; }
if (key == OpenTK.Input.Key.E) { c += "e"; }
if (key == OpenTK.Input.Key.R) { c += "r"; }
if (key == OpenTK.Input.Key.T) { c += "t"; }
if (key == OpenTK.Input.Key.Y) { c += "y"; }

But this obviously does't work for non-English alphabets.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
CommuSoft's picture

I don't know if i understand the question correctly but perhaps this helps:

c += key.ToString().ToLower();

but this only helps if you know for sure the user will only type alphanumeric characters. I have also searched to make a real keyboard-reader (that places ¨ on e, a, ... when you use conbinations, that handles backslash,... but not founded yet)

my apologies for my bad english.
The box said: "Requires Windows XP or better."
So i installed Linux.

the Fiddler's picture

Try using the GameWindow.KeyPress event, which provides a KeyChar property meant for text input. This has not been tested all that extensively, so please report any anomalies you observe!

jdomnitz's picture

Or to translate the actual keycode:

On windows: