Gamepad API and haptics
Reads buttons and sticks of a connected game controller; can trigger rumble.
In one line
Can see your game controller after you press a button, and make it rumble
Reads buttons and sticks of a connected game controller; can trigger rumble.
Shows that a controller exists and exactly how it is being used. Controller id strings leak make and model.
What it can and can't do
What the user does: You press any button on a connected controller while the page is open.
It can
- See which buttons you press and how far you move the sticks
- Make a controller rumble
- Tell which controller is connected, once you use it
It cannot
- See the controller before you press a button
- See controllers when the page is in a hidden tab in most cases
- Keep going after you close the page
- Work fully in Safari or Firefox, where rumble is limited
How it differs between platforms: Chrome and Edge fully support it. Safari and Firefox support parts, with rumble often missing.
Browser support
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 21 | 2012-07-31 | None |
| Edge | Supported | 12 | 2015-07-29 | None |
| Firefox | Partial | 29 | 2014-04-29 | No vibration actuator |
| Safari | Partial | 10.1 | 2017-03-27 | Vibration only on macOS 16.4; Vision Pro connect events fire without press |
| Safari on iPhone | Supported | 10.3 | 2017-03-27 | None |
| Chrome on Android | Supported | 25 | 2013-02-27 | None |
| Samsung Internet | Supported | 1.5 | 2013-09-25 | None |
How a site asks for it
| API | navigator.getGamepads(), gamepadconnected, gamepad.axes, gamepad.buttons, gamepad.vibrationActuator.playEffect('dual-rumble') |
| Permissions policy | gamepad |
| Browser compat keys | api.Gamepadapi.Navigator.getGamepadsapi.Gamepad.vibrationActuatorapi.GamepadHapticActuator |
| How access is granted | gesture |
| What the user sees | No prompt; the controller must be used (button press) before the page can see it |
| Needs a secure context (HTTPS) | Yes |
| Needs a user gesture | Yes |
| How long it lasts | Per session |
| How to take it back | Unplug controller |
| Inside an iframe | Gated by gamepad permissions policy (Chrome 86+) |
Typical flow
- User presses a controller button
- gamepadconnected fires
- Page polls getGamepads() every frame
Data you get
What comes back: Axes and button states
Shape: object
How often: poll per animation frame (60 Hz typical)
| Field | Type | Unit | Range | Precision |
|---|---|---|---|---|
id | string | None | controller defined | for example vendor and product id plus name; fingerprint bit source |
axes | list | None | -1 to 1 | float per axis, 4 typical |
buttons[].value | float | None | 0 to 1 | analog triggers |
mapping | enum | None | standard or empty | Not listed |
vibrationActuator effects | object | ms | duration, strongMagnitude, weakMagnitude 0 to 1 | Chrome and Safari only |
Technical limits
- Needs a button press before first exposure
- Only the focused page sees gamepads
- No rumble in Firefox
- Android Chrome limited to connected gamepads
The story
What it is
A page can read your game controller's buttons and make it rumble.
For you
You plug in or connect a controller, press a button, and the page notices it. Your controller can shake when your car hits a wall.
For makers
Makers can build console style games in a tab. It is key for cloud gaming, where the browser sends your button presses to a faraway console or PC.
Where you see it
| Type | Example | Apps |
|---|---|---|
| games | Xbox Cloud Gaming in the browser reads your Xbox controller and sends your moves to the cloud. | Xbox Cloud Gaming, GeForce NOW |
| games | A browser racing game rumbles your controller when you scrape a wall. | None named |
| media | A streaming site lets you move through menus with a controller on a TV. | YouTube TV |
| accessibility | A page lets someone with limited mobility use a special controller. | None named |
| education | A coding class teaches kids to write games that use controllers. | Scratch |
| security | A site can tell which controllers are connected, which adds to a fingerprint. | None named |
Risks
- Device fingerprint
- Accidental button presses
What the platform says
- Mozilla: Gamepad API. MDN says it lets pages read game controllers' buttons and sticks, and make them vibrate.
Good uses and abuse
Legitimate uses
- Games
- Emulators
- Accessible input
Known abuse
- Controller id as fingerprint signal
- Presence signals gamers
Scores
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 1 of 5 | How revealing the data is |
| Utility | 4 of 5 | How useful it is to honest apps |
| Friction | 0 of 5 | How much the user has to do |
| Fingerprint bits | 2 | Rough identifying entropy, when known |
History
- 2013, Chrome 21: Gamepad API ships; connected events in 25
- 2019-04, Chrome 68: vibrationActuator and haptics
- 2023-03, Safari 16.4: vibrationActuator on macOS
Related capabilities
Related
- WebHID. Can talk to one keyboard, pad or other device you pick from a list
Sources
How well checked: Checked against real behavior.