Hello Guest

Translation of key codes

  • 2 Replies
  • 5087 Views
Translation of key codes
« on: March 28, 2013, 14:57:25 »
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?

*

Offline dangerdoc

  • **
  • 75
  • Thats right... Nikola Tesla
Re: Translation of key codes
« Reply #1 on: April 24, 2013, 05:25:08 »
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.

Re: Translation of key codes
« Reply #2 on: May 02, 2013, 07:19:10 »
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 ;)