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 associatedVRDisplay
(if relevant) — theVRDisplay
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 |
GamepadThe definition of 'Gamepad' in that specification. | Working Draft | Initial definition |
WebVR 1.1The definition of 'displayId' in that specification. | Draft | Defines the Gamepad.displayId property.
|
Gamepad ExtensionsThe definition of 'Gamepad extensions' in that specification. | Editor's Draft | Defines the Experimental extensions to Gamepad |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Gamepad
|
Chrome Full support 35 Full support 35 No support 21 — 34 Prefixed' Implemented with the vendor prefix: webkit |
Edge
Full support 12 |
Firefox Full support 29 Full support 29 No support 24 — 28 Disabled' From version 24 until version 28 (exclusive): this feature is behind the |
IE
No support No |
Opera Full support 22 Full support 22 No support 15 — 21 Prefixed' Implemented with the vendor prefix: webkit |
Safari
Full support 10.1 |
WebView Android
No support No |
Chrome Android Full support 35 Full support 35 No support 25 — 34 Prefixed' Implemented with the vendor prefix: webkit |
Firefox Android
Full support 32 |
Opera Android Full support 22 Full support 22 No support 14 — 21 Prefixed' Implemented with the vendor prefix: webkit |
Safari iOS
Full support 10.3 |
Samsung Internet Android Full support 4.0 Full support 4.0 No support 2.0 — 3.0 Prefixed' Implemented with the vendor prefix: webkit |
axes
|
Chrome Full support 35 Full support 35 No support 21 — 34 Prefixed' Implemented with the vendor prefix: webkit |
Edge
Full support 12 |
Firefox Full support 29 Full support 29 No support 24 — 28 Disabled' From version 24 until version 28 (exclusive): this feature is behind the |
IE
No support No |
Opera Full support 22 Full support 22 No support 15 — 21 Prefixed' Implemented with the vendor prefix: webkit |
Safari
Full support 10.1 |
WebView Android
No support No |
Chrome Android Full support 35 Full support 35 No support 25 — 34 Prefixed' Implemented with the vendor prefix: webkit |
Firefox Android
Full support 32 |
Opera Android Full support 22 Full support 22 No support 14 — 21 Prefixed' Implemented with the vendor prefix: webkit |
Safari iOS
Full support 10.3 |
Samsung Internet Android Full support 4.0 Full support 4.0 No support 2.0 — 3.0 Prefixed' Implemented with the vendor prefix: webkit |
buttons
|
Chrome Full support 35 Full support 35 No support 21 — 34 Prefixed' Implemented with the vendor prefix: webkit |
Edge
Full support 12 |
Firefox Full support 29 Full support 29 No support 24 — 28 Disabled' From version 24 until version 28 (exclusive): this feature is behind the |
IE
No support No |
Opera Full support 22 Full support 22 No support 15 — 21 Prefixed' Implemented with the vendor prefix: webkit |
Safari
Full support 10.1 |
WebView Android
No support No |
Chrome Android Full support 35 Full support 35 No support 25 — 34 Prefixed' Implemented with the vendor prefix: webkit |
Firefox Android
Full support 32 |
Opera Android Full support 22 Full support 22 No support 14 — 21 Prefixed' Implemented with the vendor prefix: webkit |
Safari iOS
Full support 10.3 |
Samsung Internet Android Full support 4.0 Full support 4.0 No support 2.0 — 3.0 Prefixed' Implemented with the vendor prefix: webkit |
connected
|
Chrome Full support 35 Full support 35 No support 25 — 34 Prefixed' Implemented with the vendor prefix: webkit |
Edge
Full support 12 |
Firefox Full support 29 Full support 29 No support 24 — 28 Disabled' From version 24 until version 28 (exclusive): this feature is behind the |
IE
No support No |
Opera Full support 22 Full support 22 No support 15 — 21 Prefixed' Implemented with the vendor prefix: webkit |
Safari
Full support 10.1 |
WebView Android
No support No |
Chrome Android Full support 35 Full support 35 No support 25 — 34 Prefixed' Implemented with the vendor prefix: webkit |
Firefox Android
Full support 32 |
Opera Android Full support 22 Full support 22 No support 14 — 21 Prefixed' Implemented with the vendor prefix: webkit |
Safari iOS
Full support 10.3 |
Samsung Internet Android Full support 4.0 Full support 4.0 No support 2.0 — 3.0 Prefixed' Implemented with the vendor prefix: webkit |
Chrome No support ? — 80 No support ? — 80 Notes' Only works on desktop in an experimental version of Chrome (other builds won't return any devices when |
Edge
Full support 15 |
Firefox Full support 55 Full support 55 Notes' Windows support was enabled in Firefox 55. Full support 64 Notes' macOS support was enabled in Firefox 64. |
IE
No support No |
Opera
? |
Safari
No support No |
WebView Android
No support No |
Chrome Android No support ? — 80 No support ? — 80 Notes' Currently supported only by Google Daydream. |
Firefox Android
Full support 55 |
Opera Android
? |
Safari iOS
No support No |
Samsung Internet Android No support ? — 13.0 No support ? — 13.0 Notes' Currently supported only by Google Daydream. | |
Chrome
No support No |
Edge
No support 15 — 79 |
Firefox Full support Yes Full support Yes Notes' The flag is enabled by default in Firefox Nightly and Beta, versions 55 and above.
Disabled' This feature is behind the |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No | |
Chrome
No support No |
Edge
No support 15 — 79 |
Firefox Full support Yes Full support Yes Notes' The flag is enabled by default in Firefox Nightly and Beta, versions 55 and above.
Disabled' This feature is behind the |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No | |
Chrome Full support 35 Full support 35 No support 21 — 34 Prefixed' Implemented with the vendor prefix: webkit |
Edge
Full support 12 |
Firefox Full support 29 Full support 29 No support 24 — 28 Disabled' From version 24 until version 28 (exclusive): this feature is behind the |
IE
No support No |
Opera Full support 22 Full support 22 No support 15 — 21 Prefixed' Implemented with the vendor prefix: webkit |
Safari
No support No |
WebView Android
No support No |
Chrome Android Full support 35 Full support 35 No support 25 — 34 Prefixed' Implemented with the vendor prefix: webkit |
Firefox Android
Full support 32 |
Opera Android Full support 22 Full support 22 No support 14 — 21 Prefixed' Implemented with the vendor prefix: webkit |
Safari iOS
No support No |
Samsung Internet Android Full support 4.0 Full support 4.0 No support 2.0 — 3.0 Prefixed' Implemented with the vendor prefix: webkit | |
Chrome Full support 35 Full support 35 No support 21 — 34 Prefixed' Implemented with the vendor prefix: webkit |
Edge
Full support 12 |
Firefox Full support 29 Full support 29 No support 24 — 28 Disabled' From version 24 until version 28 (exclusive): this feature is behind the |
IE
No support No |
Opera Full support 22 Full support 22 No support 15 — 21 Prefixed' Implemented with the vendor prefix: webkit |
Safari
Full support 10.1 |
WebView Android
No support No |
Chrome Android Full support 35 Full support 35 No support 25 — 34 Prefixed' Implemented with the vendor prefix: webkit |
Firefox Android
Full support 32 |
Opera Android Full support 22 Full support 22 No support 14 — 21 Prefixed' Implemented with the vendor prefix: webkit |
Safari iOS
Full support 10.3 |
Samsung Internet Android Full support 4.0 Full support 4.0 No support 2.0 — 3.0 Prefixed' Implemented with the vendor prefix: webkit | |
mapping
|
Chrome Full support 35 Full support 35 No support 21 — 34 Prefixed' Implemented with the vendor prefix: webkit |
Edge
Full support 12 |
Firefox Full support 29 Full support 29 No support 24 — 28 Disabled' From version 24 until version 28 (exclusive): this feature is behind the |
IE
No support No |
Opera Full support 22 Full support 22 No support 15 — 21 Prefixed' Implemented with the vendor prefix: webkit |
Safari
Full support 10.1 |
WebView Android
No support No |
Chrome Android Full support 35 Full support 35 No support 25 — 34 Prefixed' Implemented with the vendor prefix: webkit |
Firefox Android
Full support 32 |
Opera Android Full support 22 Full support 22 No support 14 — 21 Prefixed' Implemented with the vendor prefix: webkit |
Safari iOS
Full support 10.3 |
Samsung Internet Android Full support 4.0 Full support 4.0 No support 2.0 — 3.0 Prefixed' Implemented with the vendor prefix: webkit |
Chrome
No support No |
Edge
No support 15 — 79 |
Firefox Full support Yes Full support Yes Notes' The flag is enabled by default in Firefox Nightly and Beta, versions 55 and above.
Disabled' This feature is behind the |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No | |
timestamp
|
Chrome Full support 35 Full support 35 No support 21 — 34 Prefixed' Implemented with the vendor prefix: webkit |
Edge
Full support 12 |
Firefox Full support 29 Full support 29 No support 24 — 28 Disabled' From version 24 until version 28 (exclusive): this feature is behind the |
IE
No support No |
Opera Full support 22 Full support 22 No support 15 — 21 Prefixed' Implemented with the vendor prefix: webkit |
Safari
Full support 10.1 |
WebView Android
No support No |
Chrome Android Full support 35 Full support 35 No support 25 — 34 Prefixed' Implemented with the vendor prefix: webkit |
Firefox Android
Full support 32 |
Opera Android Full support 22 Full support 22 No support 14 — 21 Prefixed' Implemented with the vendor prefix: webkit |
Safari iOS
Full support 10.3 |
Samsung Internet Android Full support 4.0 Full support 4.0 No support 2.0 — 3.0 Prefixed' Implemented with the vendor prefix: webkit |
|
Chrome
Full support 68 |
Edge
Full support 79 |
Firefox
No support No |
IE
No support No |
Opera
Full support 55 |
Safari
No support No |
WebView Android
No support No |
Chrome Android
Full support 68 |
Firefox Android
No support No |
Opera Android
Full support 48 |
Safari iOS
No support No |
Samsung Internet Android
Full support 10.0 |
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.
- Non-standard. Expect poor cross-browser support.'
- Non-standard. Expect poor cross-browser support.
- Deprecated. Not for use in new websites.'
- Deprecated. Not for use in new websites.
- 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
Gamepad by Mozilla Contributors is licensed under CC-BY-SA 2.5.