Skip to Content
Platform.Ontology

Gamepad API and haptics

Reads buttons and sticks of a connected game controller; can trigger rumble.

Gets silentlyHardware and accessoriesInput devicesWeb browsersWhen the page loadsWhile you use it

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

BrowserStatusFirst versionReleasedNote
ChromeSupported212012-07-31None
EdgeSupported122015-07-29None
FirefoxPartial292014-04-29No vibration actuator
SafariPartial10.12017-03-27Vibration only on macOS 16.4; Vision Pro connect events fire without press
Safari on iPhoneSupported10.32017-03-27None
Chrome on AndroidSupported252013-02-27None
Samsung InternetSupported1.52013-09-25None

How a site asks for it

APInavigator.getGamepads(), gamepadconnected, gamepad.axes, gamepad.buttons, gamepad.vibrationActuator.playEffect('dual-rumble')
Permissions policygamepad
Browser compat keysapi.Gamepad
api.Navigator.getGamepads
api.Gamepad.vibrationActuator
api.GamepadHapticActuator
How access is grantedgesture
What the user seesNo prompt; the controller must be used (button press) before the page can see it
Needs a secure context (HTTPS)Yes
Needs a user gestureYes
How long it lastsPer session
How to take it backUnplug controller
Inside an iframeGated by gamepad permissions policy (Chrome 86+)

Typical flow

  1. User presses a controller button
  2. gamepadconnected fires
  3. 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)

FieldTypeUnitRangePrecision
idstringNonecontroller definedfor example vendor and product id plus name; fingerprint bit source
axeslistNone-1 to 1float per axis, 4 typical
buttons[].valuefloatNone0 to 1analog triggers
mappingenumNonestandard or emptyNot listed
vibrationActuator effectsobjectmsduration, strongMagnitude, weakMagnitude 0 to 1Chrome 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

TypeExampleApps
gamesXbox Cloud Gaming in the browser reads your Xbox controller and sends your moves to the cloud.Xbox Cloud Gaming, GeForce NOW
gamesA browser racing game rumbles your controller when you scrape a wall.None named
mediaA streaming site lets you move through menus with a controller on a TV.YouTube TV
accessibilityA page lets someone with limited mobility use a special controller.None named
educationA coding class teaches kids to write games that use controllers.Scratch
securityA 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

ScoreValueMeaning
Sensitivity1 of 5How revealing the data is
Utility4 of 5How useful it is to honest apps
Friction0 of 5How much the user has to do
Fingerprint bits2Rough 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
  • WebHID. Can talk to one keyboard, pad or other device you pick from a list

Sources

How well checked: Checked against real behavior.

On this page