Gamepad: index プロパティ
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.
Gamepad.index
は Gamepad
インターフェイスのプロパティで、現在システムに接続されているそれぞれの機器の整数の固有番号(自動採番)の整数を返します。
これは複数のコントローラーを識別するために使用することができます。接続が解除された後で再接続されたゲームパッドは、同じ番号を保持します。
値
数値です。
例
js
window.addEventListener("gamepadconnected", () => {
const gp = navigator.getGamepads()[0];
gamepadInfo.textContent = `Gamepad connected at index ${gp.index}: ${gp.id}.`;
});
仕様書
Specification |
---|
Gamepad # dom-gamepad-index |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
index |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.