The Gamepad API is a way for developers to access and respond to signals from gamepads and other game controllers in a simple, consistent way. It contains three interfaces, two events and one specialist function, to respond to gamepads being connected and disconnected, and to access other information about the gamepads themselves, and what buttons and other controls are currently being pressed.

Interfaces

Gamepad
Represents a gamepad/controller connected to the computer.
GamepadButton
Represents a button on one of the connected controllers.
GamepadEvent
The event object representing events fired that are related to gamepads.

Experimental Gamepad extensions

GamepadHapticActuator
Represents hardware in the controller designed to provide haptic feedback to the user (if available), most commonly vibration hardware.
GamepadPose
Represents the pose of a controller (e.g. position and orientation in 3D space) in the case of a WebVRcontroller.

See also the extensions to the Gamepad interface, for features that allow you to access the above information.

Extensions to other interfaces

 

Navigator.getGamepads()
An extension to the Navigator object that returns an array of Gamepad objects, one for each connected gamepad.

Window events

Window.ongamepadconnected
Represents an event handler that will run when a gamepad is connected (when the gamepadconnected event fires).
Window.ongamepaddisconnected
Represents an event handler that will run when a gamepad is disconnected (when the gamepaddisconnected event fires).

Tutorials and guides

Specifications

Specification Status Comment
Gamepad Extensions Editor's Draft Defines the Experimental Gamepad extensions.
Gamepad
The definition of 'The Gamepad API specification' in that specification.
Working Draft Initial definition

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support

35

21 — 34 webkit

Yes

29

24 — 281

No

22

15 — 21 webkit

No
Gamepad() constructor3512

29

24 — 281

No22 No
axes

35

21 — 34 webkit

12

29

24 — 281

No

22

15 — 21 webkit

No
buttons

35

21 — 34 webkit

12

29

24 — 281

No

22

15 — 21 webkit

No
connected

35

25 — 34 webkit

12

29

24 — 281

No

22

15 — 21 webkit

No
displayId Yes2 315565 No ? ?
hand No15 Yes6 7 No No No
hapticActuators No15 Yes6 7 No No No
id

35

21 — 34 webkit

12

29

24 — 281

No

22

15 — 21 webkit

No
index

35

21 — 34 webkit

12

29

24 — 281

No

22

15 — 21 webkit

No
mapping

35

21 — 34 webkit

12

29

24 — 281

No

22

15 — 21 webkit

No
pose No15 Yes6 7 No No No
timestamp

35

21 — 34 webkit

12

29

24 — 281

No

22

15 — 21 webkit

No
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support No

35

25 — 34 webkit

Yes32

22

15 — 21 webkit

No Yes
Gamepad() constructor No35 Yes3222 No Yes
axes No

35

25 — 34 webkit

Yes32

22

15 — 21 webkit

No Yes
buttons No

35

25 — 34 webkit

Yes32

22

15 — 21 webkit

No Yes
connected No

35

25 — 34 webkit

Yes32

22

15 — 21 webkit

No Yes
displayId No Yes4 ? ? ? ? Yes
hand No No No No No No No
hapticActuators No No No No No No No
id No

35

25 — 34 webkit

Yes32 No No Yes
index No

35

25 — 34 webkit

Yes32 No No Yes
mapping No

35

25 — 34 webkit

Yes32

22

15 — 21 webkit

No Yes
pose No No No No No No No
timestamp No

35

25 — 34 webkit

Yes32

22

15 — 21 webkit

No Yes

1. 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.

2. Only works on desktop in an experimental version of Chrome (other builds won't return any devices when Navigator.getVRDisplays() is invoked).

3. This feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.

4. Currently supported only by Google Daydream.

5. Currently only Windows support is enabled by default. Mac support is available in Firefox Nightly.

6. The flag is enabled by default in Firefox Nightly and Beta, versions 55 and above.

7. This feature is behind the dom.gamepad-extensions.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

See also

Document Tags and Contributors

Last updated by: TheTophatDemon,