by 2 contributors:

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.

The Navigator.getGamepads() method returns an array of Gamepad objects, one for each gamepad connected to the device.


 var arrayGP = navigator.getGamepads();


window.addEventListener("gamepadconnected", function(e) {
  var gp = navigator.getGamepads()[0];
  console.log("Gamepad connected at index %d: %s. %d buttons, %d axes.",
  gp.buttons.length, gp.axes.length);


Specification Status Comment
The definition of 'The Gamepad API specification' in that specification.
Working Draft Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
General support

21.0 webkit

29.0 (29.0) [1] Not supported

15.0 webkit

Not supported
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
General support Not supported Not supported Not supported Not supported Not supported

[1] Was available behind a preference since Firefox 24.

See also

Document Tags and Contributors

Contributors to this page: teoli, chrisdavidmills
Last updated by: teoli,