Skip to content

Range.events

This module holds key constants for the SCA_KeyboardSensor.

# Set a connected keyboard sensor to accept F1
import Range
co = Range.logic.getCurrentController()
# 'Keyboard' is a keyboard sensor
sensor = co.sensors["Keyboard"]
sensor.key = Range.events.F1KEY
# Do the all keys thing
import Range
co = Range.logic.getCurrentController()
# 'Keyboard' is a keyboard sensor
sensor = co.sensors["Keyboard"]
for key, input in sensor.inputs:
# key[0] == Range.events.keycode = event.type, key[1] = input
if Range.logic.KX_INPUT_JUST_ACTIVATED in input.queue:
if key == Range.events.WKEY:
# Activate Forward!
if key == Range.events.SKEY:
# Activate Backward!
if key == Range.events.AKEY:
# Activate Left!
if key == Range.events.DKEY:
# Activate Right!
# The all keys thing without a keyboard sensor (but you will
# need an always sensor with pulse mode on)
import Range
# Just shortening names here
keyboard = Range.logic.keyboard
JUST_ACTIVATED = Range.logic.KX_INPUT_JUST_ACTIVATED
if JUST_ACTIVATED in keyboard.inputs[Range.events.WKEY].queue:
print("Activate Forward!")
if JUST_ACTIVATED in keyboard.inputs[Range.events.SKEY].queue:
print("Activate Backward!")
if JUST_ACTIVATED in keyboard.inputs[Range.events.AKEY].queue:
print("Activate Left!")
if JUST_ACTIVATED in keyboard.inputs[Range.events.DKEY].queue:
print("Activate Right!")

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

  • event: key event constant from Range.events or the keyboard sensor.
    • type: int

Return type: string

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

  • type: int
  • event: key event constant from Range.events or the keyboard sensor.
    • type: bool
  • shift: set to true if shift is held.

Return type: string

Left mouse button.

Middle mouse button (wheel click).

Right mouse button.

Mouse wheel scrolled up.

Mouse wheel scrolled down.

Back side mouse button.

Forward side mouse button.

Extra mouse button 6.

Extra mouse button 7.

Horizontal mouse movement.

A key.

B key.

C key.

D key.

E key.

F key.

G key.

H key.

I key.

J key.

K key.

L key.

M key.

N key.

O key.

P key.

Q key.

R key.

S key.

T key.

U key.

V key.

W key.

X key.

Y key.

0 key on the number row (not the numpad).

1 key on the number row (not the numpad).

2 key on the number row (not the numpad).

3 key on the number row (not the numpad).

4 key on the number row (not the numpad).

5 key on the number row (not the numpad).

6 key on the number row (not the numpad).

7 key on the number row (not the numpad).

8 key on the number row (not the numpad).

Caps Lock key.

Left Ctrl key.

Left Alt key.

Right Alt key (AltGr).

Right Ctrl key.

Right Shift key.

Left arrow.

Down arrow.

Right arrow.

Numpad 0 key.

Numpad 1 key.

Numpad 2 key.

Numpad 3 key.

Numpad 4 key.

Numpad 5 key.

Numpad 6 key.

Numpad 7 key.

Numpad 8 key.

Numpad 9 key.

Numpad period key.

Numpad / key.

Numpad * key.

Numpad - key.

Numpad Enter key.

F1 key.

F2 key.

F3 key.

F4 key.

F5 key.

F6 key.

F7 key.

F8 key.

F9 key.

F10 key.

F11 key.

F12 key.

F13 key.

F14 key.

F15 key.

F16 key.

F17 key.

F18 key.

Grave accent key (`).

Backslash key ().

Backspace key.

Comma key (,).

Delete key.

End key.

Equal key (=).

Esc key.

Home key.

Insert key.

Left bracket key ([).

Line Feed key (rare on modern keyboards).

Minus key (-).

Page Down key.

Page Up key.

Pause key.

Period key (.).

Quote key (’).

Right bracket key (]).

RETKEY (Deprecated: use bge.events.ENTERKEY)

Section titled “RETKEY (Deprecated: use bge.events.ENTERKEY)”

Enter key.

Semicolon key (;).

Slash key (/).

Space bar.

Tab key.

These items exist in the engine but were not in the Range documentation. The ones marked new in Anastacio were added by Anastacio Engine.

constant

Gamepad A button.

constant

Gamepad B button.

constant

Gamepad Back/Select button.

constant

Gamepad Guide (center) button.

constant

Gamepad left shoulder button (LB).

constant

Gamepad left stick click.

constant

Gamepad D-pad down.

constant

Gamepad D-pad left.

constant

Gamepad D-pad right.

constant

Gamepad D-pad up.

constant

Gamepad right shoulder button (RB).

constant

Gamepad right stick click.

constant

Gamepad X button.

constant

Gamepad Y button.

constant

System key (Windows/Command).