Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Gamepad
  4. id

Gamepad: id property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨March 2017⁩.

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

TheGamepad.id property of theGamepadinterface returns a string containing some information about the controller.

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

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

For example, a PS2 controller returned810-3-USB Gamepad.

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

Value

A string primitive.

Examples

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

Specifications

Specification
Gamepad
# dom-gamepad-id

Browser compatibility

See also

Using the Gamepad API

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp