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.

We'd love to hear more about your role and the company you work for
Please help us by answering a few questions.

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

ブラウザーの互換性

関連情報