
Keyboard 0:
- 48 or bge.events.ZEROKEY
- 49 or bge.events.ONEKEY
- 50 or bge.events.TWOKEY
- 51 or bge.events.THREEKEY
- 52 or bge.events.FOURKEY
- 53 or bge.events.FIVEKEY
- 54 or bge.events.SIXKEY
- 55 or bge.events.SEVENKEY
- 56 or bge.events.EIGHTKEY
- 57 or bge.events.NINEKEY

Sample Code
################ get the Key Code for the key triggering the keyboard sensor
# import bge module
import bge
# get the python controller
cont = bge.logic.getCurrentController()
# get the keyboard sensor
# My keyboard sensor is named Keyboard_1
sen = cont.sensors["Keyboard_1"]
# get the keycode of the key that triggers sensor
keyCode = sen.key
Sample Code
################ set the Key Code for the key triggering the keyboard sensor
# import bge module
import bge
# get the python controller
cont = bge.logic.getCurrentController()
# get the keyboard sensor
# My keyboard sensor is named Keyboard_1
sen = cont.sensors["Keyboard_1"]
# use the 9 key to trigger the keyboard sensor
# 9 key: 57 or bge.events.NINEKEY
sen.key = bge.events.NINEKEY