Module GameKeys

Module GameKeys

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.key = GameKeys.F1KEY

Example:

       # Do the all keys thing
       import GameLogic
       import GameKeys
       
       co = GameLogic.getCurrentController()
       # 'Keyboard' is a keyboard sensor
       sensor = co.getSensor('Keyboard')
       keylist = sensor.events
       for key in keylist:
               # key[0] == GameKeys.keycode, key[1] = status
               if key[1] == GameLogic.KX_INPUT_JUST_ACTIVATED:
                       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!
Functions
string
EventToString(event)
Return the string name of a key event.
string
EventToCharacter(event, shift)
Return the string name of a key event.
Variables
  __package__ = None
Function Details

EventToString(event)

 

Return the string name of a key event. Will raise a ValueError error if its invalid.

Parameters:
  • event (int) - key event from GameKeys or the keyboard sensor.
Returns: string

EventToCharacter(event, shift)

 

Return the string name of a key event. Returns an empty string if the event cant be represented as a character.

Parameters:
  • event (int) - key event from GameKeys or the keyboard sensor.
  • shift (bool) - set to true if shift is held.
Returns: string