Function

onMouseDown

(btn: MouseButton | MouseButton[], action: (m: MouseButton) => void): KEventController

Register an event that runs every frame when certain mouse buttons are being held down.

param btn- The mouse button(s) to listen for. See

param action- The function that is run when certain mouse buttons are being held down.

// count time with left mouse button down
let mouseTime = 0;
onMouseDown("left", () => {
    mouseTime += dt();
    debug.log(`Time with mouse down: ${mouseTime});
});

returns The event controller.

since v3001.0

group Input

Function

onMouseDown

(action: (m: MouseButton) => void): KEventController

Register an event that runs every frame when any mouse button is being held down.

param action- The function that is run when any mouse button is being held down.

// count time with any mouse button down
let mouseTime = 0;
onMouseDown((m) => {
    mouseTime += dt();
});

returns The event controller.

since v3001.0

group Input

kaplay logo

Layer

Miscalenous