onKeyDown(key: Key | Key[], action: (key: Key)=>void): KEventController

Register an event that runs every frame when a key is held down.

paramkey- The key(s) to listen for.

paramaction- The function to run when the event is triggered.

// move left by SPEED pixels per frame every frame when left arrow key is being held down
onKeyDown("left", () => {
    bean.move(-SPEED, 0)
});

returnsThe event controller.

sincev2000.1

onKeyDown(action: (key: Key)=>void): KEventController

Register an event that runs every frame when any key is held down.

paramaction- The function to run when the event is triggered.

returnsThe event controller.

sincev2000.1