isButtonPressed(btn?: TButton | TButton[]): boolean

If any or certain bound button(s) are just pressed last frame on any input (keyboard, gamepad).

parambtn- The button(s) to check.

onUpdate(() => {
    if (!isButtonPressed()) return // early return as no button was pressed

    if (isButtonPressed("jump")) debug.log("Player jumped")
    if (isButtonPressed(["left", "right"])) debug.log("Player moved")
})

sincev3001.0

kaplay logo

Misc

Layer