Gamepad: connected プロパティ

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.connectedGamepad インターフェイスのプロパティで、ゲームパッドがシステムに接続されているかどうかを示す論理値を返します。

ゲームパッドが接続されている場合の値は true、そうでない場合は false となります。

論理値です。

js
const gp = navigator.getGamepads()[0];
console.log(gp.connected);

仕様書

Specification
Gamepad
# dom-gamepad-connected

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
connected

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報