Keyboard mapping

Started by Numknuf, November 19, 2003, 20:32:59

Previous topic - Next topic

Numknuf

I noticed that the keys on my norwegian keyboard didn't produce the expected results with lwjgl. When I pressed the plus on the numpad everything is okay, but minus didn't work. Pressing the plus key (not on the numpad) gives the minus. I didn't check any other keys.

elias

Are we talking key codes or translated keys here? And which OS are you using?

- elias

Numknuf

This is what I do:

if(Keyboard.isKeyDown(Keyboard.KEY_MINUS))

Pressing a key that resembles '-' doesn't activate this. But pressing the '+' key (situtated where the american '-' is) does the trick.

Tried it with both winxp and w2k.

elias

That's just it - key codes can change on international keyboards, so you will invariably stumple upon problems like that. If you need the character that appears on the key, you should use keyboard translation. Use

Keyboard.enableBuffering()
Keyboard.enableTranslation()

and read the Keyboard.character after each Keyboard.read().

- elias

Numknuf

Thanks.

I tried getting the 'int' that the keyboard reports so that I could find out what key lwjgl thinks I'm pressing. Is there a way to get this? (just curios)

elias

Not sure what you mean by "he 'int' that is reported"? If you mean the raw key code, it is quite OS dependent; every OS has its own virtual key codes.

- elias

Numknuf

When you do:

if(Keyboard.isKeyDown(Keyboard.KEY_RIGHT))

Your checking the Keyboard.KEY_RIGHT against what the keyboard reported. Is it possible to get the value you're checking against or is this the one that's OS dependent and of no value to me?

elias

It is OS dependent and of no value to you. The key codes you check against are very raw, and they have no well defined relation to your keyboard and language settings. That's where keyboard translation comes in - it does all the hard work of combining the key code with the keyboard type and language to produce a (unicode) character.

- elias

Numknuf