API Reference › Input › Input.axis
method

Input.axis

Input.axis(neg, pos) -> fixed

Returns a digital axis from two keys: +1.0 when the positive key is held, -1.0 when the negative one is, 0 otherwise (both or neither). The building block for keyboard movement; a gamepad stick feeds the analog value through the same read.

Example

program Demo {
  entry {
    Input.press('d')
    Input.poll()
    print(Math.round(Input.axis('a', 'd')))
  }
}
← All symbols