Key constants and utilities for pyglet.window.


from pyglet.window import Window
from pyglet.window import key

window = Window()

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:


KeyStateHandler Simple handler that tracks the state of keys on the keyboard.


modifiers_string(modifiers) Return a string describing a set of modifiers.
motion_string(motion) Return a string describing a text motion.
symbol_string(symbol) Return a string describing a key symbol.
user_key(scancode) Return a key symbol for a key not supported by pyglet.


compat_platform = 'linux2'

str(object=’‘) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

Table Of Contents

Previous topic

WindowExitHandler Class

Next topic

KeyStateHandler Class