Array of values for all buttons of the gamepad.
Property of apis/gamepad/Gamepadapis/gamepad/Gamepad
SyntaxNote: This property is read-only.
var result = object.buttons;
Return Value
Returns an object of type
array of doubles.
ExamplesThe Gamepad API provides a function, Navigator.getGamepads, that returns a list of all devices currently visible to the web page, as an array of Gamepad objects. When a gamepad is connected, this example reports its index, id, number of buttons, number of axes, and when the gamepad data was updated.
window.addEventListener("gamepadconnected", function(e) {
var gp = navigator.getGamepads()[e.gamepad.index];
console.log("Gamepad connected.");
console.log("Gamepad index:", gp.index);
console.log("Gamepad id:", gp.id);
console.log("Gamepad buttons:", gp.buttons.length);
console.log("Gamepad axes:", gp.axes.length);
console.log("Gamepad last updated:", gp.timestamp);
});
Related specifications
Mozilla Developer Network : Article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4