Function

onKeyDown

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

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

param key- The key(s) to listen for.

param action- 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)
});

returns The event controller.

since v2000.1

group Input

Function

onKeyDown

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

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

param action- The function to run when the event is triggered.

returns The event controller.

since v2000.1

group Input

kaplay logo

Layer

Miscalenous