"keyboard.key" always returns 0

Hi all,

I already have created a Thread in the Blender.org Forum
but unfortunately nobody will answer to it. So I will give it a try here.

The Thread is here: http://www.blender.org/forum/viewtopic.php?t=27285

Cheers
Dirk

The API states that sensor.key simply returns the keycode the sensor is looking for. Since the “key” field in your sensor is nothing, it is returning zero.

To get a list of the pressed keys, use sensor.events instead. This handles multiple keys pressed at once. For every event in the list index[0] is the keycode and index[1] is the key status.

Try changing your if-else statement at the end of the script for this :

for event in keyboard.events :
if event[0] == 129 :

[INDENT=2]owner.localPosition.x = posX[/INDENT]
else :

[INDENT=2]print(event[0])[/INDENT]

Hi Muffy,

thank you so much.

Cheers
Dirk