Keyboard: active_events

active_events
  • Returns the keys that are being pressed/held/released in this frame.

Return Type:

  • list [ keycode, state]

keycode:

  • Type:  integer
state:
  • Type:  integer
  • 0 = not active
  • 1 = just pressed
  • 2 = active
  • 3 = released
Note:
  • bge.logic.keyboard does not use the Keyboard Sensor. 
Sample Code

################## get a list of the keyboard keys being used in this frame

# import bge
import bge

# get the keyboard
keyBoard = bge.logic.keyboard

# get the keys that are being pressed/held/released in this frame
events = keyBoard.active_events