glumpy.app.window.key¶
Key constants and utilities for pyglet.window.
Usage:
from pyglet.window import Window
from pyglet.window import key
window = Window()
@window.event
def on_key_press(symbol, modifiers):
# Symbolic names:
if symbol == key.RETURN:
# Alphabet keys:
elif symbol == key.Z:
# Number keys:
elif symbol == key._1:
# Number keypad keys:
elif symbol == key.NUM_1:
# Modifiers:
if modifiers & key.MOD_CTRL:
-
class
glumpy.app.window.key.
KeyStateHandler
¶ Simple handler that tracks the state of keys on the keyboard. If a key is pressed then this handler holds a True value for it.
For example:
>>> win = window.Window >>> keyboard = key.KeyStateHandler() >>> win.push_handlers(keyboard) # Hold down the "up" arrow... >>> keyboard[key.UP] True >>> keyboard[key.DOWN] False
-
glumpy.app.window.key.
MOD_ACCEL
= 2¶ Accelerator modifier. On Windows and Linux, this is
MOD_CTRL
, on Mac OS X it’sMOD_COMMAND
.
-
glumpy.app.window.key.
modifiers_string
(modifiers)¶ Return a string describing a set of modifiers.
Example:
>>> modifiers_string(MOD_SHIFT | MOD_CTRL) 'MOD_SHIFT|MOD_CTRL'
Parameters: - modifiers : int
Bitwise combination of modifier constants.
Return type: str
-
glumpy.app.window.key.
motion_string
(motion)¶ Return a string describing a text motion.
Example:
>>> motion_string(MOTION_NEXT_WORD): 'MOTION_NEXT_WORD'
Parameters: - motion : int
Text motion constant.
Return type: str
-
glumpy.app.window.key.
symbol_string
(symbol)¶ Return a string describing a key symbol.
Example:
>>> symbol_string(BACKSPACE) 'BACKSPACE'
Parameters: - symbol : int
Symbolic key constant.
Return type: str
-
glumpy.app.window.key.
user_key
(scancode)¶ Return a key symbol for a key not supported by pyglet.
This can be used to map virtual keys or scancodes from unsupported keyboard layouts into a machine-specific symbol. The symbol will be meaningless on any other machine, or under a different keyboard layout.
Applications should use user-keys only when user explicitly binds them (for example, mapping keys to actions in a game options screen).