Description

Calling a function when a key is down

Usage

Parameters

  • key {Integer}

    Value of the key (or keys if array). Input.A or [Input.A, Input.Z] for example

  • onPressKey {Function} optional

    (optional) Function called. One parameter: the event of the button (Event Object)

Example

To avoid latency before repeating the movement, use isPressed() in render method. In the example below, use Left and Right keys :

Discussion