Gamepad API

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

Reference

The following interfaces are defined in the Gamepad API

The Gamepad API also defines some events and a specialist function:

Gamepad Window events
Specialist events on the Window object that allows us to react when a gamepad is connected or disconnected: gamepadconnected and gamepaddisconnected. Event handlers can be easily set using Window.ongamepadconnected and Window.ongamepaddisconnected.
Navigator.getGamepads()
An extension to the Navigator object that returns an array of Gamepad objects, one for each connected gamepad.

Tutorials and guides

Specifications

Specification Status Comment
Gamepad
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
35.0
29.0 (29.0) Not supported 15.0 webkit
22.0
Not supported
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
General support Not supported 32.0 (32.0) Not supported Not supported Not supported

See also

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/gamepad_api

API Experimental Gamepad API Games Overview