The example code in the API doesn’t work.
# Do the all keys thing import bge co = bge.logic.getCurrentController() # 'Keyboard' is a keyboard sensor sensor = co.sensors["Keyboard"] for key,status in sensor.events: # key == bge.events.keycode, key = status if status == bge.logic.KX_INPUT_JUST_ACTIVATED: if key == bge.events.WKEY: # Activate Forward! if key == bge.events.SKEY: # Activate Backward! if key == bge.events.AKEY: # Activate Left! if key == bge.events.DKEY: # Activate Right!
I kinda get the jist that you have to create a blank Keyboard sensor node on the Game Logic panel and be sure it’s called “Keyboard,” but I still can’t get it to work.
I would really like to get this working because relying on the Game Logic nodes for all of my keyboard inputs is becoming the bane of my existence. So many things break when I’m not sticking exclusively with Python scripting. I’ve googled this issue and can’t find a solution anywhere. I really need help. This is a roadblock in my progress right now