Module GameKeys

Module GameKeys

source code

Documentation for the GameKeys module.

This module holds key constants for the SCA_KeyboardSensor.

Alphabet keys

Number keys

Shift Modifiers

Arrow Keys

Numberpad Keys

Function Keys

Other Keys

Example:
       # Set a connected keyboard sensor to accept F1
       import GameLogic
       import GameKeys
       
       co = GameLogic.getCurrentController()
       # 'Keyboard' is a keyboard sensor
       sensor = co.getSensor('Keyboard')
       sensor.setKey(GameKeys.F1KEY)
Example:
       # Do the all keys thing
       import GameLogic
       import GameKeys

       # status: these should be added to a module somewhere
       KX_NO_INPUTSTATUS = 0
       KX_JUSTACTIVATED = 1
       KX_ACTIVE = 2
       KX_JUSTRELEASED = 3
               
       co = GameLogic.getCurrentController()
       # 'Keyboard' is a keyboard sensor
       sensor = co.getSensor('Keyboard')
       keylist = sensor.getPressedKeys()
       for key in keylist:
               # key[0] == GameKeys.keycode, key[1] = status
               if key[1] == KX_JUSTACTIVATED:
                       if key[0] == GameKeys.WKEY:
                               # Activate Forward!
                       if key[0] == GameKeys.SKEY:
                               # Activate Backward!
                       if key[0] == GameKeys.AKEY:
                               # Activate Left!
                       if key[0] == GameKeys.DKEY:
                               # Activate Right!