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

Register an event that runs when user releases mouse.

paramaction- The function that is run what the user clicks a provided mouse button.

// spawn bean where right mouse is released
onMouseRelease("right", (m) => {
    debug.log(`${m} released, spawning bean...`);
    add([
        pos(mousePos()),
        sprite("bean"),
        anchor("center"),
    ]);
});

returnsThe event controller.

sincev3001.0

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

Register an event that runs when user releases mouse.

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

paramaction- The function that is run what the user clicks a provided mouse button.

// spawn bean where right mouse is released
onMouseRelease((m) => {
    if (m == "right") {
        debug.log(`${m} released, spawning bean...`);
        add([
            pos(mousePos()),
            sprite("bean"),
            anchor("center"),
        ]);
    });
});

returnsThe event controller.

sincev3001.0

kaplay logo

Misc

Layer