MODULE v1.8.0

input

pykraken.input

Input handling and action binding

Reference

PYTHON API

bind

function
bind(name: str, actions: Sequence[InputAction]) -> None

Bind a name to a list of InputActions. Rebinding replaces the previous state, samples currently held buttons, and clears edges without synthesizing a press. Analog axes remain analog-only.

Args

  • name (str) — The identifier for this binding (e.g. "jump").
  • actions (Sequence[InputAction]) — One or more InputActions to bind.

get_axis

function
get_axis(negative: str, positive: str) -> float

Get a 1D axis value based on two opposing input actions.

Args

  • negative (str) — Name of the negative direction action (e.g. "left").
  • positive (str) — Name of the positive direction action (e.g. "right").

Returns

  • float — Value in range [-1.0, 1.0] based on input.
get_direction(up: str, right: str, down: str, left: str) -> Vec2

Get a directional vector based on named input actions.

This is typically used for WASD-style or D-pad movement.

Args

  • up (str) — Name of action for upward movement.
  • right (str) — Name of action for rightward movement.
  • down (str) — Name of action for downward movement.
  • left (str) — Name of action for leftward movement.

Returns

  • Vec2 — A normalized vector representing the intended direction.
is_just_pressed(name: str) -> bool

Check whether the aggregate action changed from released to held during the last event.poll(). Queries are read-only; repeated reads return the same result. Both edge queries can be True if a press and release occur within one poll. Controller axes are not considered for this check.

Args

  • name (str) — The name of the bound input.

Returns

  • bool — True if pressed this frame only.
is_just_released(name: str) -> bool

Check whether the last held binding was released during the last event.poll(). Queries are read-only. Both edge queries can be True within one poll. Controller axes are not considered for this check.

Args

  • name (str) — The name of the bound input.

Returns

  • bool — True if released this frame only.

is_pressed

function
is_pressed(name: str) -> bool

Check if the given action is currently being held. Controller axes are not considered for this check.

Args

  • name (str) — The name of the bound input.

Returns

  • bool — True if any action bound to the name is pressed.

unbind

function
unbind(name: str) -> None

Unbind a previously registered input name.

Args

  • name (str) — The binding name to remove.

Find your next step

Start typing to search the manual.