GamepadButton: pressed プロパティ

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.

GamepadButton.pressedGamepadButton インターフェイスのプロパティで、現在ボタンが押されている (true) か、押されていない (false) かを示す論理値を返します。

js
let gp = navigator.getGamepads()[0]; // 最初のゲームパッドオブジェクトを取得

if (gp.buttons[0].pressed) {
  // 押されているボタンに反応
}

論理値です。

仕様書

Specification
Gamepad
# dom-gamepadbutton-pressed

ブラウザーの互換性

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
pressed

Legend

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

Full support
Full support

関連情報