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

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

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

paramaction- 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});
});

returnsThe event controller.

sincev3001.0

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

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

paramaction- 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();
});

returnsThe event controller.

sincev3001.0

kaplay logo

Misc

Layer