Range.events
This module holds key constants for the SCA_KeyboardSensor.
# Set a connected keyboard sensor to accept F1import Range
co = Range.logic.getCurrentController()# 'Keyboard' is a keyboard sensorsensor = co.sensors["Keyboard"]sensor.key = Range.events.F1KEY# Do the all keys thingimport Range
co = Range.logic.getCurrentController()# 'Keyboard' is a keyboard sensorsensor = 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 herekeyboard = Range.logic.keyboardJUST_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!")Functions
Section titled “Functions”EventToString(event)
Section titled “EventToString(event)”Return the string name of a key event. Will raise a ValueError error if its invalid.
event: key event constant fromRange.eventsor the keyboard sensor.- type: int
Return type: string
EventToCharacter(event, shift)
Section titled “EventToCharacter(event, shift)”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 fromRange.eventsor the keyboard sensor.- type: bool
shift: set to true if shift is held.
Return type: string
Keys (Constants)
Section titled “Keys (Constants)”Mouse Keys
Section titled “Mouse Keys”LEFTMOUSE
Section titled “LEFTMOUSE”Left mouse button.
MIDDLEMOUSE
Section titled “MIDDLEMOUSE”Middle mouse button (wheel click).
RIGHTMOUSE
Section titled “RIGHTMOUSE”Right mouse button.
WHEELUPMOUSE
Section titled “WHEELUPMOUSE”Mouse wheel scrolled up.
WHEELDOWNMOUSE
Section titled “WHEELDOWNMOUSE”Mouse wheel scrolled down.
LEFTTHUMBMOUSE
Section titled “LEFTTHUMBMOUSE”Back side mouse button.
RIGHTTHUMBMOUSE
Section titled “RIGHTTHUMBMOUSE”Forward side mouse button.
BUTTON6MOUSE
Section titled “BUTTON6MOUSE”Extra mouse button 6.
BUTTON7MOUSE
Section titled “BUTTON7MOUSE”Extra mouse button 7.
MOUSEX
Section titled “MOUSEX”Horizontal mouse movement.
MOUSEY
Section titled “MOUSEY”Keyboard Keys
Section titled “Keyboard Keys”Alphabet keys
Section titled “Alphabet keys”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.
Number keys
Section titled “Number keys”ZEROKEY
Section titled “ZEROKEY”0 key on the number row (not the numpad).
ONEKEY
Section titled “ONEKEY”1 key on the number row (not the numpad).
TWOKEY
Section titled “TWOKEY”2 key on the number row (not the numpad).
THREEKEY
Section titled “THREEKEY”3 key on the number row (not the numpad).
FOURKEY
Section titled “FOURKEY”4 key on the number row (not the numpad).
FIVEKEY
Section titled “FIVEKEY”5 key on the number row (not the numpad).
SIXKEY
Section titled “SIXKEY”6 key on the number row (not the numpad).
SEVENKEY
Section titled “SEVENKEY”7 key on the number row (not the numpad).
EIGHTKEY
Section titled “EIGHTKEY”8 key on the number row (not the numpad).
NINEKEY
Section titled “NINEKEY”Modifiers Keys
Section titled “Modifiers Keys”CAPSLOCKKEY
Section titled “CAPSLOCKKEY”Caps Lock key.
LEFTCTRLKEY
Section titled “LEFTCTRLKEY”Left Ctrl key.
LEFTALTKEY
Section titled “LEFTALTKEY”Left Alt key.
RIGHTALTKEY
Section titled “RIGHTALTKEY”Right Alt key (AltGr).
RIGHTCTRLKEY
Section titled “RIGHTCTRLKEY”Right Ctrl key.
RIGHTSHIFTKEY
Section titled “RIGHTSHIFTKEY”Right Shift key.
LEFTSHIFTKEY
Section titled “LEFTSHIFTKEY”Arrow Keys
Section titled “Arrow Keys”LEFTARROWKEY
Section titled “LEFTARROWKEY”Left arrow.
DOWNARROWKEY
Section titled “DOWNARROWKEY”Down arrow.
RIGHTARROWKEY
Section titled “RIGHTARROWKEY”Right arrow.
UPARROWKEY
Section titled “UPARROWKEY”Numberpad Keys
Section titled “Numberpad Keys”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.
PADPERIOD
Section titled “PADPERIOD”Numpad period key.
PADSLASHKEY
Section titled “PADSLASHKEY”Numpad / key.
PADASTERKEY
Section titled “PADASTERKEY”Numpad * key.
PADMINUS
Section titled “PADMINUS”Numpad - key.
PADENTER
Section titled “PADENTER”Numpad Enter key.
PADPLUSKEY
Section titled “PADPLUSKEY”Function Keys
Section titled “Function Keys”F1 key.
F2 key.
F3 key.
F4 key.
F5 key.
F6 key.
F7 key.
F8 key.
F9 key.
F10KEY
Section titled “F10KEY”F10 key.
F11KEY
Section titled “F11KEY”F11 key.
F12KEY
Section titled “F12KEY”F12 key.
F13KEY
Section titled “F13KEY”F13 key.
F14KEY
Section titled “F14KEY”F14 key.
F15KEY
Section titled “F15KEY”F15 key.
F16KEY
Section titled “F16KEY”F16 key.
F17KEY
Section titled “F17KEY”F17 key.
F18KEY
Section titled “F18KEY”F18 key.
F19KEY
Section titled “F19KEY”Other Keys
Section titled “Other Keys”ACCENTGRAVEKEY
Section titled “ACCENTGRAVEKEY”Grave accent key (`).
BACKSLASHKEY
Section titled “BACKSLASHKEY”Backslash key ().
BACKSPACEKEY
Section titled “BACKSPACEKEY”Backspace key.
COMMAKEY
Section titled “COMMAKEY”Comma key (,).
DELKEY
Section titled “DELKEY”Delete key.
ENDKEY
Section titled “ENDKEY”End key.
EQUALKEY
Section titled “EQUALKEY”Equal key (=).
ESCKEY
Section titled “ESCKEY”Esc key.
HOMEKEY
Section titled “HOMEKEY”Home key.
INSERTKEY
Section titled “INSERTKEY”Insert key.
LEFTBRACKETKEY
Section titled “LEFTBRACKETKEY”Left bracket key ([).
LINEFEEDKEY
Section titled “LINEFEEDKEY”Line Feed key (rare on modern keyboards).
MINUSKEY
Section titled “MINUSKEY”Minus key (-).
PAGEDOWNKEY
Section titled “PAGEDOWNKEY”Page Down key.
PAGEUPKEY
Section titled “PAGEUPKEY”Page Up key.
PAUSEKEY
Section titled “PAUSEKEY”Pause key.
PERIODKEY
Section titled “PERIODKEY”Period key (.).
QUOTEKEY
Section titled “QUOTEKEY”Quote key (’).
RIGHTBRACKETKEY
Section titled “RIGHTBRACKETKEY”Right bracket key (]).
RETKEY (Deprecated: use bge.events.ENTERKEY)
Section titled “RETKEY (Deprecated: use bge.events.ENTERKEY)”ENTERKEY
Section titled “ENTERKEY”Enter key.
SEMICOLONKEY
Section titled “SEMICOLONKEY”Semicolon key (;).
SLASHKEY
Section titled “SLASHKEY”Slash key (/).
SPACEKEY
Section titled “SPACEKEY”Space bar.
TABKEY
Section titled “TABKEY”Tab key.
Not in the Range documentation
Section titled “Not in the Range documentation”These items exist in the engine but were not in the Range documentation. The ones marked new in Anastacio were added by Anastacio Engine.
JOYSTICKA
Section titled “JOYSTICKA”constant
Gamepad A button.
JOYSTICKB
Section titled “JOYSTICKB”constant
Gamepad B button.
JOYSTICKBACK
Section titled “JOYSTICKBACK”constant
Gamepad Back/Select button.
JOYSTICKGUIDE
Section titled “JOYSTICKGUIDE”constant
Gamepad Guide (center) button.
JOYSTICKLEFTSHOUDER
Section titled “JOYSTICKLEFTSHOUDER”constant
Gamepad left shoulder button (LB).
JOYSTICKLEFTSTICK
Section titled “JOYSTICKLEFTSTICK”constant
Gamepad left stick click.
JOYSTICKPADDOWN
Section titled “JOYSTICKPADDOWN”constant
Gamepad D-pad down.
JOYSTICKPADLEFT
Section titled “JOYSTICKPADLEFT”constant
Gamepad D-pad left.
JOYSTICKPADRIGHT
Section titled “JOYSTICKPADRIGHT”constant
Gamepad D-pad right.
JOYSTICKPADUP
Section titled “JOYSTICKPADUP”constant
Gamepad D-pad up.
JOYSTICKRIGHTSHOUDER
Section titled “JOYSTICKRIGHTSHOUDER”constant
Gamepad right shoulder button (RB).
JOYSTICKRIGHTSTICK
Section titled “JOYSTICKRIGHTSTICK”constant
Gamepad right stick click.
JOYSTICKX
Section titled “JOYSTICKX”constant
Gamepad X button.
JOYSTICKY
Section titled “JOYSTICKY”constant
Gamepad Y button.
constant
System key (Windows/Command).
