The Gamepad interface of the Gamepad API defines an individual gamepad or other controller, allowing access to information such as button presses, axis positions, and id.

A Gamepad object can be returned in one of two ways: via the gamepad property of the gamepadconnected and gamepaddisconnected events, or by grabbing any position in the array returned by the Navigator.getGamepads() method.


Gamepad.displayId Read only
Returns the VRDisplay.displayId of the associated VRDisplay — the VRDisplay that the gamepad is controlling the displayed scene of. Read only
A DOMString containing identifying information about the controller.
Gamepad.index Read only
An integer that is auto-incremented to be unique for each device currently connected to the system.
Gamepad.mapping Read only
A string indicating whether the browser has remapped the controls on the device to a known layout.
Gamepad.connected Read only
A boolean indicating whether the gamepad is still connected to the system.
Gamepad.buttons Read only
An array of gamepadButton objects representing the buttons present on the device.
Gamepad.axes Read only
An array representing the controls with axes present on the device (e.g. analog thumb sticks).
Gamepad.timestamp Read only
A DOMHighResTimeStamp representing the last time the data for this gamepad was updated. Note that this property is not currently supported anywhere.


window.addEventListener("gamepadconnected", function(e) {
  console.log("Gamepad connected at index %d: %s. %d buttons, %d axes.",
  e.gamepad.buttons.length, e.gamepad.axes.length);


Specification Status Comment
The definition of 'Gamepad' in that specification.
Working Draft Initial defintion
The definition of 'displayId' in that specification.
Editor's Draft Defines the Gamepad.displayId property.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
General support 21.0 webkit
29.0 (29.0) No support 15.0 webkit
No support
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
General support No support 32.0 (32.0) No support No support No support

See also


© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.

API Gamepad API Games Interface Reference