Input
Input handling and action binding
Bind
bind(
name: str,
actions: Sequence[InputAction]
) → NoneBind a name to a list of InputActions.
Args
name: The identifier for this binding (e.g. "jump").actions: One or more InputActions to bind.
Get Axis
get_axis(negative: str, positive: str) → floatGet a 1D axis value based on two opposing input actions.
Args
negative: Name of the negative direction action (e.g. "left").positive: Name of the positive direction action (e.g. "right").
Returns
float : Value in range [-1.0, 1.0] based on input.
Get Direction
get_direction(
up: str,
right: str,
down: str,
left: str
) → Vec2Get a directional vector based on named input actions.
This is typically used for WASD-style or D-pad movement.
Args
up: Name of action for upward movement.right: Name of action for rightward movement.down: Name of action for downward movement.left: Name of action for leftward movement.
Returns
Vec2 : A normalized vector representing the intended direction.
Is Just Pressed
is_just_pressed(name: str) → boolCheck if the given action was just pressed this frame.
Args
name: The name of the bound input.
Returns
bool : True if pressed this frame only.
Is Just Released
is_just_released(name: str) → boolCheck if the given action was just released this frame.
Args
name: The name of the bound input.
Returns
bool : True if released this frame only.
Is Pressed
is_pressed(name: str) → boolCheck if the given action is currently being held.
Args
name: The name of the bound input.
Returns
bool : True if any action bound to the name is pressed.
Unbind
unbind(name: str) → NoneUnbind a previously registered input name.
Args
name: The binding name to remove.