Search found 2 matches

by dschiller
Fri May 24, 2013 8:56 am
Forum: Python
Topic: "keyboard.key" always returns 0
Replies: 1
Views: 1002

Re: "keyboard.key" always returns 0

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] ...
by dschiller
Wed May 08, 2013 8:02 am
Forum: Python
Topic: "keyboard.key" always returns 0
Replies: 1
Views: 1002

"keyboard.key" always returns 0

Hi all, here is my code: import bge cont = bge.logic.getCurrentController() owner = cont.owner mouse = cont.sensors["Mouse2"] keyboard = cont.sensors["Keyboard2"] width = bge.render.getWindowWidth() width = width/2 pos = mouse.position posX = width-pos[0] posX = posX*0.02*-1 if keyboard.getKeyStatus...