API Reference › Input › Input.vector
method

Input.vector

Input.vector(left, right, up, down) -> Vector

Returns a 2D movement Vector from four direction keys, normalized so a diagonal is not faster than a straight move (each diagonal component is 0.7071). The one call for eight-way keyboard movement.

Example

program Demo {
  entry {
    Input.press('d')
    Input.press('w')
    Input.poll()
    let v = Input.vector('a', 'd', 'w', 's')
    print(Math.round(Vector.x(v) * 100))
  }
}
← All symbols