onGamepadButtonPress(btn: KGamepadButton | KGamepadButton[], action: (btn: KGamepadButton, gamepad: KGamepad)=>void): KEventController

Register an event that runs when user presses certain gamepad button.

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

paramaction- The function that is run when certain gamepad buttons are pressed.

// when user presses button
onGamepadButtonPress("south", (btn, gp) => {
    player.jump(200);
});

returnsThe event controller.

sincev3001.0

onGamepadButtonPress(action: (btn: KGamepadButton, gamepad: KGamepad)=>void): KEventController

Register an event that runs when user presses any gamepad button.

paramaction- The function that is run when any gamepad buttons is pressed.

// when user presses button
onGamepadButtonPress((btn, gp) => {
    if (btn == "south") {
        player.jump(200);     // jump
    }
});

returnsThe event controller.

sincev3001.0

kaplay logo

Misc

Layer