Grease logo

Previous topic

grease.controller – General Behavioral Aspects

Next topic

grease.entity – Entity Classes

This Page

grease.controls – Game Controls

Control systems for binding controls to game logic

class grease.controls.KeyControls[source]

System that maps subclass-defined action methods to keys.

Keys may be mapped in the subclass definition using decorators defined here as class methods or at runtime using the bind_key_* instance methods.

See an example implementation in the tutorial.

bind_key_hold(method, key, modifiers=0)[source]

Bind a method to a key at runtime to be invoked when the key is held down, this replaces any existing key hold binding for this key. To unbind the key entirely, pass None for method.

bind_key_press(method, key, modifiers=0)[source]

Bind a method to a key at runtime to be invoked when the key is initially pressed, this replaces any existing key hold binding for this key. To unbind the key entirely, pass None for method.

bind_key_release(method, key, modifiers=0)[source]

Bind a method to a key at runtime to be invoked when the key is releaseed, this replaces any existing key hold binding for this key. To unbind the key entirely, pass None for method.

classmethod key_hold(symbol, modifiers=0)[source]

Decorator to bind a method to be executed where a key is held down

classmethod key_press(symbol, modifiers=0)[source]

Decorator to bind a method to be executed where a key is initially depressed

classmethod key_release(symbol, modifiers=0)[source]

Decorator to bind a method to be executed where a key is released

on_key_press(key, modifiers)[source]

Handle pyglet key press. Invoke key press methods and activate key hold functions

on_key_release(key, modifiers)[source]

Handle pyglet key release. Invoke key release methods and deactivate key hold functions

step(dt)[source]

invoke held key functions

MODIFIER_MASK

The MODIFIER_MASK allows you to filter out modifier keys that should be ignored by the application. By default, numlock and scrolllock are ignored.

world

grease.World object this system is bound to