W3cubDocs

/Web APIs

Gamepad API

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

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 WebVR controller. This is not used by the newer WebXR standard.

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

gamepadconnected

An event that will fire when a gamepad is connected.

gamepaddisconnected

An event that will fire when a gamepad is disconnected.

Tutorials and guides

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
Gamepad_API 21 12 29 No 15 10.1 4.4 25 32 14 10.3 1.5
axes 21 12 29 No 15 10.1 4.4 25 32 14 10.3 1.5
buttons 21 12 29 No 15 10.1 4.4 25 32 14 10.3 1.5
connected 25 12 29 No 15 10.1 4.4 25 32 14 10.3 1.5
displayId No 79–8015–79 98
64–98macOS support was enabled in Firefox 64.
55–98Windows support was enabled in Firefox 55.
No No No No
55–80Currently supported only by Google Daydream.
55
42–57Currently supported only by Google Daydream.
No
6.0–13.0Currently supported only by Google Daydream.
hand No 15–79 55 No No No No No 55 No No No
hapticActuators No 15–79 55 No No No No No 55 No No No
id 21 12 29 No 15 10.1 4.4 25 32 14 10.3 1.5
index 21 12 29 No 15 10.1 4.4 25 32 14 10.3 1.5
mapping 21 12 29 No 15 10.1 4.4 25 32 14 10.3 1.5
pose No 15–79 55 No No No No No 55 No No No
secure_context_required 86 86 91 No 72 No No 86 91 No No No
timestamp 21 12 29 No 15 10.1 4.4 25 32 14 10.3 1.5
vibrationActuator 68 79 No No 55 16.4 No 68 No 48 16.4 10.0

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API