-
-
Notifications
You must be signed in to change notification settings - Fork 53
Unified Input and Input Bindings
Daniel Báez edited this page Jun 14, 2024
·
2 revisions
Defining input bindings in CONFIG
kaplay({
// Define buttons
buttons: {
up: { keyboard: ["w", "up"], controller: ["dpad-up"] },
},
saveButtons: true, // save them in localStorage? (idea)
});
Setting and getting input bindings in runtime
setButton("up", {
keyboard: ["w"],
controller: ["dpad-up"],
});
getButton("up") // get the up bindings
Using input bindings
onButtonPress("up") // work as onGamepadButtonPress("dpad-up") and onKeyPress("up")
onButtonDown("up")
onButtonRelease("up")