GamepadButton: value プロパティ

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.valueGamepadButton インターフェイスのプロパティで、トリガーなど、現代の多くのゲームパッドにおけるアナログボタンの現在の状態を表すために使用する double 値を返します。

値は 0.0 - 1.0 の範囲で正規化され、0.0 は押されていないボタン、1.0 は完全に押されたボタンを表します。

js
let gp = navigator.getGamepads()[0];

if (gp.buttons[0].value > 0) {
  // アナログボタンが押されたことに対する反応
}

A double.

仕様書

Specification
Gamepad
# dom-gamepadbutton-value

ブラウザーの互換性

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
value

Legend

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

Full support
Full support

関連情報