Translation of key codes

Started by aleator, March 28, 2013, 14:57:25

Previous topic - Next topic

aleator

Hello guys and gals,

first of, thanks for providing this neat little library. It works great (even on OS X 10.8 with Java 7 using LWJGL 2.9.x).

And now right to the question: how would one go about the translation of Keyboard.getEventKey() into a meaningful, speaking name on different keyboard layouts?

Consider the following scenario: I've got a configurable key setup, if I want to reset a button I click on it and the game queries the next key pressed (i.e. the usual key binding mechanism). I now want to tell the user which key he just bound.

Furthermore - if I've got some sort of tutorial - I want to tell the user: "press <button> to <JUMP>."

Obviously I can't use Keyboard.getKeyName() for this because it would render 'Z' when the user presses 'Y' on a German QWERTZ keyboard.
I can't use Keyboard.getEventCharacter() either because it doesn't return anything meaningful for keys like CIRCUMFLEX, SPACE or TAB.

Is there already an existing library that can handle such things or would I have to roll my own?

dangerdoc

It just has different layout... Pressing Z on a german keyboard = pressing Z on an english keyboard, and same for Y. I believe that the Operating System handles things such as this for different keyboard layouts. Ask someone to try it on a german keyboard. It should work unless the person is using an OS that doesnt support keyboard layouts.
“We build but to tear down. Most of our work and resource is squandered. Our onward march is marked by devastation. Everywhere there is an appalling loss of time, effort and life. A cheerless view, but true.” - Nikola Tesla

Evil-Devil

The easiest way to get around with it is to use a custom mapper. Several keys will be identical on allmost every keyboard...the others need to be remapped by the user.

@german keyboard: I could try it ;)