API Reference › Input › Input.strength
method

Input.strength

Input.strength(action) -> fixed

Returns the 0.0..1.0 strength of a named action — 1.0 when any bound key is held, 0 otherwise for keys (digital), and the analog magnitude when a gamepad feeds the action. Lets analog and digital sources share one read.

Example

program Demo {
  entry {
    Input.bind("gas", 'w')
    Input.press('w')
    Input.poll()
    print(Math.round(Input.strength("gas")))
  }
}
← All symbols