API Reference › Input › Input.bind
method

Input.bind

Input.bind(action: str, key: int) -> void

Binds a physical key (a character code such as 'w' or ' ') to a named action, creating the action the first time it is named. Gameplay then reads the action with Input.down / Input.pressed instead of a raw key, which is what makes rebinding and alternate control schemes clean. Call it more than once with the same action to bind several keys to it; binding a key already on the action is a no-op. Actions are advanced once per frame by Input.poll.

Example

program Bindings {
  entry {
    Input.bind("jump", ' ')
    Input.bind("up", 'w')
    Input.poll()
    if Input.down("jump") { print(1) }
  }
}
← All symbols