Gamepad: id property

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The property of the Gamepad interface returns a string containing some information about the controller.

The exact syntax is not strictly specified, but in Firefox it will contain three pieces of information separated by dashes (-):

  • Two 4-digit hexadecimal strings containing the USB vendor and product id of the controller
  • The name of the controller as provided by the driver.

For example, a PS2 controller returned 810-3-USB Gamepad.

This information is intended to allow you to find a mapping for the controls on the device as well as display useful feedback to the user.


A string primitive.


window.addEventListener("gamepadconnected", () => {
  const gp = navigator.getGamepads()[0];
  gamepadInfo.textContent = `Gamepad connected at index ${gp.index}: ${}.`;


# dom-gamepad-id

Browser compatibility

BCD tables only load in the browser

See also