API Reference › Input › Input.rebind
method

Input.rebind

Input.rebind(action: str, from: int, to: int) -> void

Replaces the key from with to on a named action, at runtime — the primitive a "press a key to rebind" options screen is built on. A no-op if the action does not exist or is not bound to from. Because gameplay reads actions, not keys, a rebind takes effect immediately with no change to the game logic.

Example

program Rebinding {
  entry {
    Input.bind("jump", ' ')
    Input.rebind("jump", ' ', 'x')
    Input.poll()
    if Input.down("jump") { print(1) }
  }
}
← All symbols