Gamepad API

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.

* Some parts of this feature may have varying levels of support.

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.

Extensions to other interfaces

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

Specification
Gamepad
# gamepad-interface
Gamepad Extensions
# partial-gamepad-interface

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Gamepad
axes
buttons
connected
displayId
DeprecatedNon-standard
hand
Experimental
hapticActuators
Experimental
id
index
mapping
pose
Experimental
Secure context required
Experimental
timestamp
vibrationActuator

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.
User must explicitly enable this feature.
Has more compatibility info.

See also