input — Handling input from keyboard, mouse and controllers

InputManager reference

class input.InputManager

Input manager object can be accessed via Scene.input property. It has three main features:

And a number of other minor features.

Instance Properties:

InputManager.keyboard

A get accessor returning KeyboardManager object which exposes methods to check for keyboard input. See the KeyboardManager documentation for a full list of available methods.

InputManager.mouse

A get accessor returning MouseManager object which exposes methods to check for mouse input. See the MouseManager documentation for a full list of available methods.

InputManager.controller

A get accessor returning ControllerManager object which exposes methods to check for controller input. See the ControllerManager documentation for a full list of available methods.

InputManager.system

A get accessor returning SystemManager object which exposes methods to check for system input. See the SystemManager documentation for a full list of available methods.

InputManager.cursor_visible

Gets or sets the visibility of the mouse cursor as bool.

Instance Methods:

InputManager.events()

Returns a list of Event objects that ocurred during the last frame. Check out the Event instance documentation for details.

InputManager.register_callback(event_type, callback_func)

Registers a callback function which will be called when specific event type(s) occur. Allows for an easy consumption of events you’re interested in.

The event_type parameter must be a specific Event subtype. You can also pass an iterable of those. Represents event type(s) you want to subscribe to.

The callback_func must be a callable. It will get called each time given event type occurs, passing the event as parameter.

from kaa.input import EventType

def on_text_input(event):
    print('user typed this: {}'.format(event.keyboard_text.text))

def on_mouse_event(event):
    print('mouse button/wheel stuff happened!')

# somewhere inside a Scene instance...
self.input.register_callback(Event.keyboard_text, on_text_input)
self.input.register_callback([Event.mouse_button, Event.mouse_wheel], on_mouse_event)

Only one callback for given event type can be registered at a time. Registering another callback with the same event type will overwrite the previous one:

from kaa.input import EventType

def on_text_input_1(event):
    print('1 - user typed this: {}'.format(event.keyboard_text.text))

def on_text_input_2(event):
    print('2 - user typed this: {}'.format(event.keyboard_text.text))

# somewhere inside a Scene instance...
self.input.register_callback(Event.keyboard_text, on_text_input_1)
# this will cancel the previous callback (i.e. on_text_input_1 will never be called):
self.input.register_callback(Event.keyboard_text, on_text_input_2)

If you pass None as callback_func, it will unregister the currently existing callback for that even type or do nothing if no callback for that type is currently registered.

from kaa.input import EventType

def on_text_input(event):
    print('user typed this: {}'.format(event.keyboard_text.text))

# somewhere inside a Scene instance...
self.input.register_callback(Event.keyboard_text, on_text_input)
self.input.register_callback(Event.keyboard_text, None) # unregisters the callback, on_text_input won't be called

KeyboardManager reference

class input.KeyboardManager

Keyboard manager can be accessed via the InputManager.keyboard property.

It allows to check the state (pressed or released) of given key.

Instance methods:

KeyboardManager.is_pressed(keycode)

Checks if a specific key is pressed - keycode param must be a Keycode enum value.

from kaa.input import Keycode

# somewhere inside a Scene instance...
if self.input.keyboard.is_pressed(Keycode.w):
    # ... do something if w is pressed
if self.input.keyboard.is_pressed(Keycode.W):
    # ... do something if W is pressed
if self.input.keyboard.is_pressed(Keycode.return_):
    # ... do something if ENTER key is pressed
KeyboardManager.is_released(keycode)

Checks if a specific key is released - keycode param must be a Keycode enum value.

from kaa.input import Keycode

# somewhere inside a Scene instance...
if self.input.keyboard.is_released(Keycode.w):
    # ... do something if w is released
if self.input.keyboard.is_released(Keycode.W):
    # ... do something if W is released
if self.input.keyboard.is_released(Keycode.return_):
    # ... do something if ENTER key is released

MouseManager reference

class input.MouseManager

Mouse manager can be accessed via the InputManager.mouse property.

The manager allows to check for the mouse buttons state (pressed/released). It also allows to get the mouse pointer position.

Instance properties:

MouseManager.relative_mode

Gets or sets relative mode (as bool). Default is False. Enabling relative mode has two effects: it hides the mouse pointer and it makes mouse motion events (MouseMotionEvent) be published all the time (by default those events are published only if mouse moves within game’s window). Disabling the relative mode shows the mouse pointer and makes mouse motion events be published only if mouse movement occurs within the window.

MouseManager.cursor_visible

Gets or sets whether the system cursor pointer should be visible.

Instance methods:

MouseManager.is_pressed(mousebutton)

Checks if given mouse button is pressed - mousebutton param must be a MouseButton enum value.

from kaa.input import MouseButton

#somewhere inside a Scene instance...
if self.input.mouse.is_pressed(MouseButton.left):
    # do something if the left mouse button is pressed
MouseManager.is_released(mousebutton)

Checks if given mouse button is released - mousebutton param must be a MouseButton enum value.

from kaa.input import MouseButton

#somewhere inside a Scene instance...
if self.input.mouse.is_released(MouseButton.middle):
    # do something if the middle mouse button is released
MouseManager.get_position()

Returns current mouse pointer position as a geometry.Vector.

IMPORTANT: the position is in the display screen frame of reference using the virtual resolution coordinate system). It is NOT a position of a mouse cursor on the scene. To convert the position to the scene frame of reference use the engine.Camera.unproject_position() method.

#somewhere inside a Scene instance...
pos = self.input.mouse.get_position():
print(pos)  # V[145.234, 345.343]

ControllerManager reference

class input.ControllerManager

Controller Manager can be accessed via the InputManager.controller property.

The manager exposes methods for checking the state of controller’s buttons, sticks and triggers. All major controller types are supported.

Unlike mouse or keyboard, multiple controllers can be connected and used simultaneously, therefore all manager methods require passing a controller ID.

You can get the controller ID when controller is first connected. Kaa engine will publish a ControllerEvent having connected flag set to True. An id field on the event is the controller ID you’re looking for.

When a controller disconnects, you will receive a ControllerEvent with connected flag set to True.

Your game code should always keep track of all currently connected controllers (their IDs).

Below is a basic example of keeping track of connected controller IDs and checking few selected properties of each connected controller:

from kaa.engine import Engine, Scene
from kaa.geometry import Vector
from kaa.input import Keycode, ControllerButton, ControllerAxis

class MyScene(Scene):

    def __init__(self):
        self.connected_controller_ids = []
        self.frame_count = 0

    def update(self, dt):
        self.frame_count += 1
        for event in self.input.events():

            if event.controller_device:
                if event.controller_device.is_added:
                    print('New controller connected: id is {}'.format(event.controller_device.id))
                    self.connected_controller_ids.append(event.controller_device.id)
                elif event.controller_device.is_removed:
                    print('Controller disconnected: id is {}'.format(event.controller_device.id))
                    self.connected_controller_ids.remove(event.controller_device.id)

            if event.system and event.system.quit:
                self.engine.quit()

        # Check a few properties of each connected controller:
        for controller_id in self.connected_controller_ids:
            a_button_pressed = self.input.controller.is_pressed(ControllerButton.a, controller_id)
            b_button_pressed = self.input.controller.is_pressed(ControllerButton.b, controller_id)
            left_stick_x = self.input.controller.get_axis_motion(ControllerAxis.left_x, controller_id)
            left_stick_y = self.input.controller.get_axis_motion(ControllerAxis.left_y, controller_id)
            print('Controller {}. A pressed:{}, B pressed:{}, left stick pos: {},{}'.format(controller_id,
                a_button_pressed, b_button_pressed, left_stick_x, left_stick_y))


with Engine(virtual_resolution=Vector(400, 200)) as engine:
    scene = MyScene()
    engine.window.size = Vector(400, 200)
    engine.window.center()
    engine.run(scene)

Instance methods

ControllerManager.is_connected(controller_id)

Checks connection status of a given controller_id.

ControllerManager.is_pressed(controller_button, controller_id)

Checks if given controller button is pressed. The controller_button param must be a ControllerButton enum value. Check out the example above on how to obtain the controller_id.

For example, to check the state of B button on controller 0:

from kaa.input import ControllerButton

# somewhere in the Scene class:
if self.input.controller.is_pressed(ControllerButton.b, 0):
    print('B is pressed on controller 0!')
ControllerManager.is_released(controller_button, controller_id)

Checks if given controller button is released on given controller. The controller_button param must be a ControllerButton enum value. Check out the example above on how to obtain the controller_id.

For example, to check the state of B button on controller 2:

from kaa.input import ControllerButton

# somewhere in the Scene class:
if self.input.controller.is_released(ControllerButton.b, 2):
    print('B is released on controller 2!')
ControllerManager.is_axis_pressed(axis, controller_id)

Checks if given stick axes or trigger is in non-zero position. The axis param must be of ControllerAxis enum value. Check out the example above on how to obtain the controller_id.

For example, to check if controller 1 left trigger is pressed:

from kaa.input import ControllerAxis

# somewhere in the Scene class:
if self.input.controller.is_axis_pressed(ControllerAxis.trigger_left, 1):
    print('Left trigger is pressed!')
ControllerManager.is_axis_released(axis, controller_id)

Same as above, but checks if given stick axes or trigger is in a zero position. The axis param must be of ControllerAxis enum value. Check out the example above on how to obtain the controller_id.

ControllerManager.get_axis_motion(axis, controller_id)

Gets an exact value of given stick axes motion or trigger as a number between 0 (stick axes or trigger in zero position) and 1 (stick axes or trigger in max position). The axis param must be of ControllerAxis enum value. Check out the example above on how to obtain the controller_id.

For example, to check the state of controller 0 left trigger:

from kaa.input import ControllerAxis

# somewhere in the Scene class:
val = self.input.controller.get_axis_motion(ControllerAxis.trigger_right, 0):
print('Controller 0, pulling left trigger {} percent :)'.format(val*100))
ControllerManager.get_name(controller_id)

Returns a name of a controller. Check out the example above on how to obtain the controller_id.

ControllerManager.get_triggers(controller_id)

Returns state of both triggers in a single geometry.Vector object. Vector’s x value is left trigger and vector’s y is right trigger. Check out the example above on how to obtain the controller_id.

The values returned are between 0 (trigger is fully released) to 1 (trigger is fully pressed)

ControllerManager.get_sticks(compound_axis, controller_id)

Returns state of given stick as a geometry.Vector.

The compound_axis parameter must be of CompoundControllerAxis enum value.

Check out the example above on how to obtain the controller_id.

For example, to get the controller 1 left stick position:

# somewhere in the Scene class:
val = self.input.controller.get_axis_motion(CompoundControllerAxis.left_stick, 1):
print('Controller 1, left stick position is {}'.format(val))

SystemManager reference

class input.SystemManager

System Manager can be accessed via the InputManager.system property.

The manager exposes methods for working with system related input such as clipboard.

Instance methods:

SystemManager.get_clipboard_text()

Gets text from the system clipboard

SystemManager.set_clipboard_text(text)

Puts the text in the system clipboard

Event reference

class input.Event

As the game is running, a lot of things happen: the player may press or release keyboard keys or mouse buttons, interact with controller, he can also interact with the window in which your game is running, e.g. maximize or minimize it, and so on. Kaa engine detects all those events and makes them consumable either via InputManager.events() method or by registering a callback function InputManager.register_callback().

Each Event instance has identical structure with the following instance properties:

  • type - returns event type

  • timestamp - returns time of the event occurrence

  • system - stores SystemEvent instance if this event is a system related event, otherwise it will be None

  • window - stores WindowEvent instance if this event is a window related event, otherwise it will be None

  • keyboard_key - stores KeyboardKeyEvent instance if this event is a keyboard key related event, otherwise it will be None

  • keyboard_text - stores KeyboardTextEvent instance if this event is a keyboard text related event, otherwise it will be None

  • mouse_button - stores MouseButtonEvent instance if this event is a mouse button related event, otherwise it will be None

  • mouse_motion - stores MouseMotionEvent instance if this event is a mouse motion related event, otherwise it will be None

  • mouse_wheel - stores MouseWheelEvent instance if this event is a mouse wheel related event, otherwise it will be None

  • controller_device - stores ControllerDeviceEvent instance if this event is a controller device related event, otherwise it will be None

  • controller_button - stores ControllerButtonEvent instance if this event is a controller button related event, otherwise it will be None

  • controller_axis - stores ControllerAxisEvent instance if this event is a controller axis related event, otherwise it will be None

  • audio - stores AudioEvent instance if this event is an audio related event, otherwise it will be None

Depending on the type of the event only one property will be non-null while all the other properties will be null. This design usually results in a following way of handling events in the code:

# ... inside a Scene...
def update(self, dt):

    for event in self.input.events():
        if event.system:
            # do something if it's a system event
        elif event.window:
            # do something if it's a window event
        elif event.keyboard_key:
            # do something if it's a keyboard key event
        elif event.keyboard_text:
            # do something if it's a keyboard text event
        elif event.mouse_button:
            # do something if it's a mouse button event
        elif event.controller_button:
            # do something if it's a controller button event
        elif event.audio:
            # do something if it's audio event
        # ... and so on ...

Event class also has descriptors (“static properties”) that return appropariate event types:

which allows checking the type property on the event instance:

# ... inside a Scene...
def update(self, dt):

    for event in self.input.events():
        if event.type == Event.system:
            # do something
        elif event.type == Event.keyboard_key:
            # do something ...
        elif event.type == Event.controller_axis:
            # do something ...
        # ... and so on

KeyboardKeyEvent reference

class input.KeyboardKeyEvent

Represents an event of pressing or releasing a keyboard key.

See also: KeyboardTextEvent

Instance properties:

KeyboardEvent.key

Returns the key this event is referring to, as Keycode enum value.

KeyboardEvent.is_key_down

Returns True if the key was pressed.

KeyboardEvent.is_key_up

Returns True if the key was released.

KeyboardTextEvent reference

class input.KeyboardTextEvent

Represents an event of text being produced by the keyboard buffer. It lets you conveniently work with the text being typed in by the player.

Instance properties:

KeyboardTextEvent.text

Returns string with the text typed in.

For example, imagine a user with a polish keyboard pressing shift key, right alt and ‘s’ keys, holding it for some time and then releasing all pressed keys.

In a text editor it would result in typing something like this:

ŚŚŚŚŚŚ

The way ths will be represented in the kaaengine event flow:

  1. You will first receive three KeyboardKeyEvent events: one for pressing the shift key, another for pressing the alt key and one for pressing the s key

  2. You will then receive a number of KeyboardTextEvent events, in this case we have six ‘Ś’ characters typed, so you will get six events. Reading the text property on KeyboardTextEvent will return “Ś” string.

  3. Finally, you will first receive three KeyboardKeyEvent events: one for releasing the shift key, another for releasing the alt key and another one for releasing the s key

MouseButtonEvent reference

class input.MouseButtonEvent

Represents a mouse button related event, such as pressing or releasing a mouse button.

# ... inside a Scene instance...
for event in self.input.events():
    if event.mouse_button:
        if event.mouse_button.is_button_down:
            print("Mouse button {} is DOWN. Mouse position: {}.".format(event.mouse_button.button,
                  event.mouse_button.position))
        elif event.mouse_button.is_button_up:
            print("Mouse button {} is UP. Mouse position: {}.".format(event.mouse_button.button,
                  event.mouse_button.position))

Instance properties:

MouseButtonEvent.button

Returns the button this event is referring to, as MouseButton enum value.

MouseButtonEvent.is_button_down

Returns True if the button was pressed.

MouseButtonEvent.is_button_up

Returns True if the button was released.

MouseButtonEvent.position

Returns mouse pointer position, at the moment of the click, as geometry.Vector. IMPORTANT: the position is in the display screen frame of reference (using the virtual resolution coordinate system). It is NOT a position of a mouse cursor on the scene. To convert the position to the scene frame of reference use the engine.Camera.unproject_position() method on the Camera object.

# somewhere inside the Scene instance:
for event in self.input.events():
    if event.mouse_button:
        if event.mouse_button.is_button_down and event.mouse_button.button == MouseButton.left:
            mouse_pos_absolute = event.mouse_button.position
            mouse_pos_on_scene = self.camera.unproject_position(mouse_pos_absolute)

MouseMotionEvent reference

class input.MouseMotionEvent

Represents a mouse motion event (changing mouse pointer position). By default those events are published when mouse pointer is within the window. You can enable the relative_mode on the MouseManager - it hides the mouse pointer and makes mouse motion events be published whenever the pointer is moved (inside or outside of the window).

# ... inside a Scene instance...
for event in self.input.events():
    if event.mouse_motion:
         print("Mouse motion detected! New position is: {}.".format(event.mouse_motion.position))

Instance properties:

MouseMotionEvent.position

Returns mouse pointer position as geometry.Vector. IMPORTANT: the position is in the display screen frame of reference (using the virtual resolution coordinate system). It is NOT a position of a mouse cursor on the scene. To convert the position to the scene frame of reference use the engine.Camera.unproject_position() method on the Camera object.

# somewhere inside the Scene instance:
for event in self.input.events():
    if event.mouse_motion:
        mouse_pos_absolute = event.mouse_button.position
        mouse_pos_on_scene = self.camera.unproject_position(mouse_pos_absolute)
MouseMotionEvent.motion

Returns mouse pointer motion (difference between the current and previous position) as geometry.Vector.

MouseWheelEvent reference

class input.MouseWheelEvent

Represents a mouse wheel related event.

Instance properties:

MouseWheelEvent.scroll

Returns a geometry.Vector indicating whether the mouse wheel was scrolled up or down. The y property in the returned vector holds the value, the x will always be zero.

# ... inside a Scene instance...
for event in self.input.events():
    if event.mouse_wheel:
        print("Mouse wheel event detected. Scroll is: {}.".format(event.mouse_wheel.scroll))

ControllerDeviceEvent reference

Represents a controller device related event, such as controller connected or disconnected.

class input.ControllerDeviceEvent
# ... inside a Scene instance...
for event in self.input.events():
    if event.controller_device:
        if event.controller_device.is_added:
            print("Controller with id={} connected.".format(event.controller_device.id)
        elif event.controller_device.is_removed:
            print("Controller with id={} disconnected.".format(event.controller_device.id)

Instance properties:

ControllerDeviceEvent.id

Returns an id of controller this event is referring to.

ControllerDeviceEvent.is_added

Returns True if controller was connected.

ControllerDeviceEvent.is_removed

Returns True if controller was disconnected.

ControllerButtonEvent reference

Represents a controller button related event, such as controller button pressed or released.

class input.ControllerButtonEvent

Note: Controller triggers are considered sticks (axis) not buttons! Use ControllerAxisEvent to check out events representing triggers changing state.

# ... inside a Scene instance...
for event in self.input.events():
    if event.controller_button:
        if event.controller_button.is_button_down:
            print("Controller button {} on controller id={} was pressed.".format(
                  event.controller_button.button, event.controller_button.id)
        elif event.controller_button.is_button_up:
            print("Controller button {} on controller id={} was released.".format(
                  event.controller_button.button, event.controller_button.id)

Instance properties:

ControllerButtonEvent.id

Returns an id of controller this event is referring to.

ControllerButtonEvent.button

Returns controller button this event is referring to, as ControllerButton enum value.

ControllerButtonEvent.is_button_down

Returns True if the button was pressed.

ControllerButtonEvent.is_button_up

Returns True if the button was released.

ControllerAxisEvent reference

Represents a controller axis related event, such as controller stick or trigger state change.

# ... inside a Scene instance...
for event in self.input.events():
    if event.controller_axis:
        print("Controller axis {} on controller id={} changed its state. New state is {}.".format(
              event.controller_axis.axis, event.controller_axis.id, event.controller_axis.motion)
class input.ControllerAxisEvent

Instance properties

ControllerAxisEvent.id

Returns an id of controller this event is referring to.

ControllerAxisEvent.axis

Returns axis (controller stick or trigger) this event is referring to, as ControllerAxis enum value.

ControllerAxisEvent.motion

Returns the axis (controller stick or trigger) state, as a geometry.Vector. The length of the vector will be between 0 (stick or trigger is in neutral position) and 1 (stick or trigger is in its maximum position)

AudioEvent reference

class input.AudioEvent

Represents an audio related event.

Instance properties:

AudioEvent.music_finished

Returns True if current music track finished playing.

WindowEvent reference

class input.WindowEvent

Represents a window related event.

Instance properties:

WindowEvent.is_shown

Returns True if the window was shown.

WindowEvent.is_exposed

Returns True if the window was exposed.

WindowEvent.is_moved

Returns True if the window was moved.

WindowEvent.is_resized

Returns True if the window was resized.

WindowEvent.is_minimized

Returns True if the window was minimized.

WindowEvent.is_maximized

Returns True if the window was maximized.

WindowEvent.is_restored

Returns True if the window was restored.

WindowEvent.is_enter

Returns True if the mouse pointer entered the window area.

WindowEvent.is_leave

Returns True if the mouse pointer left the window area.

WindowEvent.is_focus_gained

Returns True if the window gained a focus.

WindowEvent.is_focus_lost

Returns True if the window lost a focus.

WindowEvent.is_close

Returns True if the window was closed.

SystemEvent reference

class input.SystemEvent

Represents a system related event.

Instance properties:

SystemEvent.quit

Returns True if the game proces is terminating.

SystemEvent.clipboard_updated

Returns True if the system clipboard was updated. You may call SystemManager.get_clipboard_text() method to check out the text in the system clipboard.

Keycode reference

class input.Keycode

Enum type for referencing keyboard keys when working with KeyboardManager and KeyboardKeyEvent.

Available values are:

  • Keycode.unknown

  • Keycode.return_

  • Keycode.escape

  • Keycode.backspace

  • Keycode.tab

  • Keycode.space

  • Keycode.exclaim

  • Keycode.quotedbl

  • Keycode.hash

  • Keycode.percent

  • Keycode.dollar

  • Keycode.ampersand

  • Keycode.quote

  • Keycode.leftparen

  • Keycode.rightparen

  • Keycode.asterisk

  • Keycode.plus

  • Keycode.comma

  • Keycode.minus

  • Keycode.period

  • Keycode.slash

  • Keycode.num_0

  • Keycode.num_1

  • Keycode.num_2

  • Keycode.num_3

  • Keycode.num_4

  • Keycode.num_5

  • Keycode.num_6

  • Keycode.num_7

  • Keycode.num_8

  • Keycode.num_9

  • Keycode.colon

  • Keycode.semicolon

  • Keycode.less

  • Keycode.equals

  • Keycode.greater

  • Keycode.question

  • Keycode.at

  • Keycode.leftbracket

  • Keycode.backslash

  • Keycode.rightbracket

  • Keycode.caret

  • Keycode.underscore

  • Keycode.backquote

  • Keycode.a

  • Keycode.b

  • Keycode.c

  • Keycode.d

  • Keycode.e

  • Keycode.f

  • Keycode.g

  • Keycode.h

  • Keycode.i

  • Keycode.j

  • Keycode.k

  • Keycode.l

  • Keycode.m

  • Keycode.n

  • Keycode.o

  • Keycode.p

  • Keycode.q

  • Keycode.r

  • Keycode.s

  • Keycode.t

  • Keycode.u

  • Keycode.v

  • Keycode.w

  • Keycode.x

  • Keycode.y

  • Keycode.z

  • Keycode.A

  • Keycode.B

  • Keycode.C

  • Keycode.D

  • Keycode.E

  • Keycode.F

  • Keycode.G

  • Keycode.H

  • Keycode.I

  • Keycode.J

  • Keycode.K

  • Keycode.L

  • Keycode.M

  • Keycode.N

  • Keycode.O

  • Keycode.P

  • Keycode.Q

  • Keycode.R

  • Keycode.S

  • Keycode.T

  • Keycode.U

  • Keycode.V

  • Keycode.W

  • Keycode.X

  • Keycode.Y

  • Keycode.Z

  • Keycode.capslock

  • Keycode.F1

  • Keycode.F2

  • Keycode.F3

  • Keycode.F4

  • Keycode.F5

  • Keycode.F6

  • Keycode.F7

  • Keycode.F8

  • Keycode.F9

  • Keycode.F10

  • Keycode.F11

  • Keycode.F12

  • Keycode.printscreen

  • Keycode.scrolllock

  • Keycode.pause

  • Keycode.insert

  • Keycode.home

  • Keycode.pageup

  • Keycode.delete

  • Keycode.end

  • Keycode.pagedown

  • Keycode.right

  • Keycode.left

  • Keycode.down

  • Keycode.up

  • Keycode.numlockclear

  • Keycode.kp_divide

  • Keycode.kp_multiply

  • Keycode.kp_minus

  • Keycode.kp_plus

  • Keycode.kp_enter

  • Keycode.kp_1

  • Keycode.kp_2

  • Keycode.kp_3

  • Keycode.kp_4

  • Keycode.kp_5

  • Keycode.kp_6

  • Keycode.kp_7

  • Keycode.kp_8

  • Keycode.kp_9

  • Keycode.kp_0

  • Keycode.kp_period

  • Keycode.application

  • Keycode.power

  • Keycode.kp_equals

  • Keycode.F13

  • Keycode.F14

  • Keycode.F15

  • Keycode.F16

  • Keycode.F17

  • Keycode.F18

  • Keycode.F19

  • Keycode.F20

  • Keycode.F21

  • Keycode.F22

  • Keycode.F23

  • Keycode.F24

  • Keycode.execute

  • Keycode.help

  • Keycode.menu

  • Keycode.select

  • Keycode.stop

  • Keycode.again

  • Keycode.undo

  • Keycode.cut

  • Keycode.copy

  • Keycode.paste

  • Keycode.find

  • Keycode.mute

  • Keycode.volumeup

  • Keycode.volumedown

  • Keycode.kp_comma

  • Keycode.kp_equalsas400

  • Keycode.alterase

  • Keycode.sysreq

  • Keycode.cancel

  • Keycode.clear

  • Keycode.prior

  • Keycode.return2

  • Keycode.separator

  • Keycode.out

  • Keycode.oper

  • Keycode.clearagain

  • Keycode.crsel

  • Keycode.exsel

  • Keycode.kp_00

  • Keycode.kp_000

  • Keycode.thousandsseparator

  • Keycode.decimalseparator

  • Keycode.currencyunit

  • Keycode.currencysubunit

  • Keycode.kp_leftparen

  • Keycode.kp_rightparen

  • Keycode.kp_leftbrace

  • Keycode.kp_rightbrace

  • Keycode.kp_tab

  • Keycode.kp_backspace

  • Keycode.kp_a

  • Keycode.kp_b

  • Keycode.kp_c

  • Keycode.kp_d

  • Keycode.kp_e

  • Keycode.kp_f

  • Keycode.kp_xor

  • Keycode.kp_power

  • Keycode.kp_percent

  • Keycode.kp_less

  • Keycode.kp_greater

  • Keycode.kp_ampersand

  • Keycode.kp_dblampersand

  • Keycode.kp_verticalbar

  • Keycode.kp_dblverticalbar

  • Keycode.kp_colon

  • Keycode.kp_hash

  • Keycode.kp_space

  • Keycode.kp_at

  • Keycode.kp_exclam

  • Keycode.kp_memstore

  • Keycode.kp_memrecall

  • Keycode.kp_memclear

  • Keycode.kp_memadd

  • Keycode.kp_memsubtract

  • Keycode.kp_memmultiply

  • Keycode.kp_memdivide

  • Keycode.kp_plusminus

  • Keycode.kp_clear

  • Keycode.kp_clearentry

  • Keycode.kp_binary

  • Keycode.kp_octal

  • Keycode.kp_decimal

  • Keycode.kp_hexadecimal

  • Keycode.lctrl

  • Keycode.lshift

  • Keycode.lalt

  • Keycode.lgui

  • Keycode.rctrl

  • Keycode.rshift

  • Keycode.ralt

  • Keycode.rgui

  • Keycode.mode

  • Keycode.audionext

  • Keycode.audioprev

  • Keycode.audiostop

  • Keycode.audioplay

  • Keycode.audiomute

  • Keycode.mediaselect

  • Keycode.www

  • Keycode.mail

  • Keycode.calculator

  • Keycode.computer

  • Keycode.ac_search

  • Keycode.ac_home

  • Keycode.ac_back

  • Keycode.ac_forward

  • Keycode.ac_stop

  • Keycode.ac_refresh

  • Keycode.ac_bookmarks

  • Keycode.brightnessdown

  • Keycode.brightnessup

  • Keycode.displayswitch

  • Keycode.kbdillumtoggle

  • Keycode.kbdillumdown

  • Keycode.kbdillumup

  • Keycode.eject

  • Keycode.sleep

MouseButton reference

class input.MouseButton

Enum type for referencing mouse buttons when working with MouseManager and MouseButtonEvent.

Available values are:

  • MouseButton.left

  • MouseButton.middle

  • MouseButton.right

  • MouseButton.x1

  • MouseButton.x2

ControllerButton reference

class input.ControllerButton

Enum type for referencing controller buttons when working with ControllerManager and ControllerButtonEvent. Note that left and right triggers are not buttons, they’re considered axis (see ControllerAxisEvent)

Available values are:

  • ControllerButton.a

  • ControllerButton.b

  • ControllerButton.x

  • ControllerButton.y

  • ControllerButton.back

  • ControllerButton.guide

  • ControllerButton.start

  • ControllerButton.left_stick

  • ControllerButton.right_stick

  • ControllerButton.left_shoulder

  • ControllerButton.right_shoulder

  • ControllerButton.dpad_up

  • ControllerButton.dpad_down

  • ControllerButton.dpad_left

  • ControllerButton.dpad_right

ControllerAxis reference

class input.ControllerAxis

Enum type for referencing controller axes when working with ControllerManager and ControllerAxisEvent.

Available values are:

  • ControllerAxis.left_y

  • ControllerAxis.left_x

  • ControllerAxis.right_x

  • ControllerAxis.right_y

  • ControllerAxis.trigger_left

  • ControllerAxis.trigger_right

CompoundControllerAxis reference

class input.CompoundControllerAxis

Enum type for referencing sticks (left or right) when working with some of ControllerManager methods.

Available values are:

  • CompoundControllerAxis.left_stick

  • CompoundControllerAxis.right_stick