Expand description
Functions and types relating to handling the player’s input.
§Gamepads
When accessing gamepad state, you specify which gamepad you’re interested in via a ‘gamepad ID’. The first gamepad connected to the system has ID 0, the second has ID 1, and so on.
If a controller is disconnected, the next controller to be connected will take its ID - otherwise, a new one will be allocated. This means that if you unplug a controller and then plug it back in, it should retain its existing ID. This behaviour might be made smarter in future versions.
§Examples
The keyboard
example demonstrates how to handle keyboard input.
The mouse
example demonstrates how to handle mouse input.
The gamepad
example demonstrates how to handle gamepad input.
The text_input
example demonstrates how to handle text entry.
Enums§
- Gamepad
Axis - An axis of movement on a gamepad.
- Gamepad
Button - A button on a gamepad.
- Gamepad
Stick - A control stick on a gamepad.
- Key
- A physical key on a keyboard.
- KeyLabel
- A key, as represented by the current system keyboard layout.
- KeyModifier
- A key modifier on the keyboard.
- Mouse
Button - A button on a mouse.
Functions§
- get_
clipboard_ text - Gets the text currently stored in the system’s clipboard.
- get_
gamepad_ axis_ position - Returns the current position of the specified gamepad axis.
- get_
gamepad_ buttons_ down - Returns an iterator of the buttons that are currently down on the specified gamepad.
- get_
gamepad_ buttons_ pressed - Returns an iterator of the buttons that were pressed on the specified gamepad since the last update.
- get_
gamepad_ buttons_ released - Returns an iterator of the buttons that were released on the specified gamepad since the last update .
- get_
gamepad_ name - Returns the name of the specified gamepad, or
None
if it is not connected. - get_
gamepad_ stick_ position - Returns the current position of the specified gamepad control stick.
- get_
key_ label - Returns the label for the specified key in the current keyboard layout.
- get_
key_ with_ label - Returns the key that has the specified label in the current keyboard layout.
- get_
keys_ down - Returns an iterator of the keys that are currently down.
- get_
keys_ pressed - Returns an iterator of the keys that were pressed since the last update.
- get_
keys_ released - Returns an iterator of the keys that were released since the last update.
- get_
mouse_ position - Get the position of the mouse.
- get_
mouse_ wheel_ movement - Get the amount that the mouse wheel moved since the last update.
- get_
mouse_ x - Get the X co-ordinate of the mouse.
- get_
mouse_ y - Get the Y co-ordinate of the mouse.
- get_
text_ input - Returns the text that the user entered since the last update. This will match the user’s keyboard and OS settings.
- is_
gamepad_ button_ down - Returns true if the specified gamepad button is currently down.
- is_
gamepad_ button_ pressed - Returns true if the specified gamepad button was pressed since the last update.
- is_
gamepad_ button_ released - Returns true if the specified gamepad button was released since the last update.
- is_
gamepad_ button_ up - Returns true if the specified gamepad button is currently up.
- is_
gamepad_ connected - Returns true if the specified gamepad is currently connected.
- is_
gamepad_ vibration_ supported - Returns true if the specified gamepad supports vibration.
- is_
key_ down - Returns true if the specified key is currently down.
- is_
key_ modifier_ down - Returns true if the specified key modifier is currently down.
- is_
key_ modifier_ up - Returns true if the specified key modifier is currently up.
- is_
key_ pressed - Returns true if the specified key was pressed since the last update.
- is_
key_ released - Returns true if the specified key was released since the last update.
- is_
key_ up - Returns true if the specified key is currently up.
- is_
mouse_ button_ down - Returns true if the specified mouse button is currently down.
- is_
mouse_ button_ pressed - Returns true if the specified mouse button was pressed since the last update.
- is_
mouse_ button_ released - Returns true if the specified mouse button was released since the last update.
- is_
mouse_ button_ up - Returns true if the specified mouse button is currently up.
- is_
mouse_ scrolled_ down - Returns true if the user scrolled down since the last update.
- is_
mouse_ scrolled_ up - Returns true if the user scrolled up since the last update.
- set_
clipboard_ text - Sets the contents of the system’s clipboard.
- set_
gamepad_ vibration - Sets the specified gamepad’s motors to vibrate indefinitely.
- start_
gamepad_ vibration - Sets the specified gamepad’s motors to vibrate for a set duration, specified in milliseconds. After this time has passed, the vibration will automatically stop.
- stop_
gamepad_ vibration - Stops the specified gamepad’s motors from vibrating.