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.

Properties

Gamepad.axes Read only
An array representing the controls with axes present on the device (e.g. analog thumb sticks).
Gamepad.buttons Read only
An array of gamepadButton objects representing the buttons present on the device.
Gamepad.connected Read only
A boolean indicating whether the gamepad is still connected to the system.
Gamepad.displayId Read only
Returns the VRDisplay.displayId of an associated VRDisplay (if relevant) — the VRDisplay that the gamepad is controlling the displayed scene of.
Gamepad.id 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.timestamp Read only
A DOMHighResTimeStamp representing the last time the data for this gamepad was updated.

Experimental extensions to Gamepad

The following interfaces are defined in the Gamepad Extensions specification, and provide access to experimental features like haptic feedback and WebVR controller pose information.

Gamepad.hand Read only
An enum defining what hand the controller is being held in, or is most likely to be held in.
Gamepad.hapticActuators Read only
An array containing GamepadHapticActuator objects, each of which represents haptic feedback hardware available on the controller.
Gamepad.pose Read only
A GamepadPose object representing the pose information associated with a WebVR controller (e.g. its position and orientation in 3D space).

Example

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

Specifications

Specification Status Comment
Gamepad
The definition of 'Gamepad' in that specification.
Working Draft Initial definition
WebVR 1.1
The definition of 'displayId' in that specification.
Draft Defines the Gamepad.displayId property.
Gamepad Extensions
The definition of 'Gamepad extensions' in that specification.
Editor's Draft Defines the Experimental extensions to Gamepad

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support 35
Full support 35
No support 21 — 34
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support YesFirefox Full support 29
Full support 29
No support 24 — 28
Disabled
Disabled From version 24 until version 28 (exclusive): this feature is behind the dom.gamepad.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 22
Full support 22
No support 15 — 21
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari No support NoWebView Android No support NoChrome Android Full support 35
Full support 35
No support 25 — 34
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile Full support YesFirefox Android Full support 32Opera Android Full support 22
Full support 22
No support 15 — 21
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari iOS No support NoSamsung Internet Android Full support Yes
Gamepad() constructorChrome Full support 35Edge Full support 12Firefox Full support 29
Full support 29
No support 24 — 28
Disabled
Disabled From version 24 until version 28 (exclusive): this feature is behind the dom.gamepad.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 22Safari No support NoWebView Android No support NoChrome Android Full support 35Edge Mobile Full support YesFirefox Android Full support 32Opera Android Full support 22Safari iOS No support NoSamsung Internet Android Full support Yes
axesChrome Full support 35
Full support 35
No support 21 — 34
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support 12Firefox Full support 29
Full support 29
No support 24 — 28
Disabled
Disabled From version 24 until version 28 (exclusive): this feature is behind the dom.gamepad.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 22
Full support 22
No support 15 — 21
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari No support NoWebView Android No support NoChrome Android Full support 35
Full support 35
No support 25 — 34
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile Full support YesFirefox Android Full support 32Opera Android Full support 22
Full support 22
No support 15 — 21
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari iOS No support NoSamsung Internet Android Full support Yes
buttonsChrome Full support 35
Full support 35
No support 21 — 34
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support 12Firefox Full support 29
Full support 29
No support 24 — 28
Disabled
Disabled From version 24 until version 28 (exclusive): this feature is behind the dom.gamepad.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 22
Full support 22
No support 15 — 21
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari No support NoWebView Android No support NoChrome Android Full support 35
Full support 35
No support 25 — 34
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile Full support YesFirefox Android Full support 32Opera Android Full support 22
Full support 22
No support 15 — 21
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari iOS No support NoSamsung Internet Android Full support Yes
connectedChrome Full support 35
Full support 35
No support 25 — 34
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support 12Firefox Full support 29
Full support 29
No support 24 — 28
Disabled
Disabled From version 24 until version 28 (exclusive): this feature is behind the dom.gamepad.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 22
Full support 22
No support 15 — 21
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari No support NoWebView Android No support NoChrome Android Full support 35
Full support 35
No support 25 — 34
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile Full support YesFirefox Android Full support 32Opera Android Full support 22
Full support 22
No support 15 — 21
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari iOS No support NoSamsung Internet Android Full support Yes
displayId
Experimental
Chrome Full support Yes
Notes Disabled
Full support Yes
Notes Disabled
Notes Only works on desktop in an experimental version of Chrome (other builds won't return any devices when Navigator.getVRDisplays() is invoked).
Disabled This feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Edge Full support 15Firefox Full support 55
Notes
Full support 55
Notes
Notes Windows support was enabled in Firefox 55.
Full support 64
Notes
Notes macOS support was enabled in Firefox 64.
IE No support NoOpera ? Safari ? WebView Android No support NoChrome Android Full support Yes
Notes
Full support Yes
Notes
Notes Currently supported only by Google Daydream.
Edge Mobile ? Firefox Android Full support 55Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes
hand
Experimental
Chrome No support NoEdge Full support 15Firefox Full support Yes
Notes Disabled
Full support Yes
Notes Disabled
Notes The flag is enabled by default in Firefox Nightly and Beta, versions 55 and above.
Disabled This feature is behind the dom.gamepad-extensions.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support No
hapticActuators
Experimental
Chrome No support NoEdge Full support 15Firefox Full support Yes
Notes Disabled
Full support Yes
Notes Disabled
Notes The flag is enabled by default in Firefox Nightly and Beta, versions 55 and above.
Disabled This feature is behind the dom.gamepad-extensions.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support No
id
Experimental
Chrome Full support 35
Full support 35
No support 21 — 34
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support 12Firefox Full support 29
Full support 29
No support 24 — 28
Disabled
Disabled From version 24 until version 28 (exclusive): this feature is behind the dom.gamepad.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 22
Full support 22
No support 15 — 21
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari No support NoWebView Android No support NoChrome Android Full support 35
Full support 35
No support 25 — 34
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile Full support YesFirefox Android Full support 32Opera Android No support NoSafari iOS No support NoSamsung Internet Android Full support Yes
index
Experimental
Chrome Full support 35
Full support 35
No support 21 — 34
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support 12Firefox Full support 29
Full support 29
No support 24 — 28
Disabled
Disabled From version 24 until version 28 (exclusive): this feature is behind the dom.gamepad.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 22
Full support 22
No support 15 — 21
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari No support NoWebView Android No support NoChrome Android Full support 35
Full support 35
No support 25 — 34
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile Full support YesFirefox Android Full support 32Opera Android No support NoSafari iOS No support NoSamsung Internet Android Full support Yes
mappingChrome Full support 35
Full support 35
No support 21 — 34
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support 12Firefox Full support 29
Full support 29
No support 24 — 28
Disabled
Disabled From version 24 until version 28 (exclusive): this feature is behind the dom.gamepad.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 22
Full support 22
No support 15 — 21
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari No support NoWebView Android No support NoChrome Android Full support 35
Full support 35
No support 25 — 34
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile Full support YesFirefox Android Full support 32Opera Android Full support 22
Full support 22
No support 15 — 21
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari iOS No support NoSamsung Internet Android Full support Yes
pose
Experimental
Chrome No support NoEdge Full support 15Firefox Full support Yes
Notes Disabled
Full support Yes
Notes Disabled
Notes The flag is enabled by default in Firefox Nightly and Beta, versions 55 and above.
Disabled This feature is behind the dom.gamepad-extensions.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support No
timestampChrome Full support 35
Full support 35
No support 21 — 34
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support 12Firefox Full support 29
Full support 29
No support 24 — 28
Disabled
Disabled From version 24 until version 28 (exclusive): this feature is behind the dom.gamepad.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 22
Full support 22
No support 15 — 21
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari No support NoWebView Android No support NoChrome Android Full support 35
Full support 35
No support 25 — 34
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile Full support YesFirefox Android Full support 32Opera Android Full support 22
Full support 22
No support 15 — 21
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari iOS No support NoSamsung Internet Android Full support Yes

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

See also

Document Tags and Contributors

Contributors to this page: jpmedley, fscholz, chrisdavidmills, codl, erikadoyle, teoli, Sebastianz, jsx
Last updated by: jpmedley,