konchai
v0.2.0
Published
<p align="center" dir="auto"> <img width="180" src="https://raw.githubusercontent.com/twitter/twemoji/d94f4cf793e6d5ca592aa00f58a88f6a4229ad43/assets/svg/1f9cb.svg" alt="Bubble Tea" style="max-width: 100%;"> </p>
Downloads
1
Readme
Konchai
Gamepad event listener library
Usage
import { gamepad } from "konchai";
const gp = gamepad();
// Listen to any button
const unlisten1 = gp.change((name, value) => {
console.log(name, value);
if (gp.state.buttons.right && gp.state.buttons["face-top"]) {
console.log("> + ^");
}
});
// Listen to certain button
const unlisten2 = gp.on("home", (value) =>
console.log(value ? "Home Pressed" : "Home Unpressed")
);
document.getElementById("stop-listen-to-gamepad-events-button").onclick =
() => {
unlisten1(), unlisten2();
};