coderef

GamepadBaseline · Widely available

The navigator.getGamepads() API accesses and responds to signals from game controllers.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Mar 27, 2017. Widely available since Sep 27, 2019.

Browser support

DesktopChrome
1–34Not supported
35+Supportedsince May 20, 2014
Current: 155
Edge
12+Supportedsince Jul 29, 2015
Current: 154
Firefox
1–28Not supported
29+Supportedsince Apr 29, 2014
Current: 157
Safari
1–10Not supported
10.1+Supportedsince Mar 27, 2017
Current: 27
MobileChrome Android
18–34Not supported
35+Supportedsince May 20, 2014
Current: 155
Firefox Android
4–31Not supported
32+Supportedsince Sep 2, 2014
Current: 157
Safari iOS
1–10Not supported
10.3+Supportedsince Mar 27, 2017
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: Gamepad.

Feature detection

JS · check before using
if ("Gamepad" in globalThis) {
  // Gamepad is available
} else {
  // load a polyfill or use a fallback
}

Sub-features

Support for each part of the feature (18). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
Gamepad21122910.1253210.3
Gamepad.axes21122910.1253210.3
Gamepad.buttons21122910.1253210.3
Gamepad.connected25122910.1253210.3
Gamepad.id21122910.1253210.3
Gamepad.index21122910.1253210.3
Gamepad.mapping21122910.1253210.3
Gamepad.timestamp21122910.1253210.3
GamepadButton21122910.1253210.3
GamepadButton.pressed21122910.1253210.3
GamepadButton.value21122910.1253210.3
GamepadEvent21122910.1253210.3
GamepadEvent.GamepadEvent35122910.1353210.3
GamepadEvent.gamepad21122910.1253210.3
Navigator.getGamepads35122910.1353210.3
Window.gamepadconnected_event14314389161438916
Window.gamepaddisconnected_event14314389161438916
iframe.allow.gamepad✕✕✕✕✕✕✕