From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/gamepadbutton/value/index.html | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 files/zh-cn/web/api/gamepadbutton/value/index.html (limited to 'files/zh-cn/web/api/gamepadbutton/value') diff --git a/files/zh-cn/web/api/gamepadbutton/value/index.html b/files/zh-cn/web/api/gamepadbutton/value/index.html new file mode 100644 index 0000000000..a7c83775a8 --- /dev/null +++ b/files/zh-cn/web/api/gamepadbutton/value/index.html @@ -0,0 +1,53 @@ +--- +title: GamepadButton.value +slug: Web/API/GamepadButton/value +translation_of: Web/API/GamepadButton/value +--- +

{{APIRef("Gamepad API")}}

+ +

{{domxref("GamepadButton")}}接口下的 GamepadButton.value 属性返回一个双精浮点值来表示许多现代控制器上的模拟按钮的状态,比如说扳机键。

+ +

其值被规范于范围 0.01.0 内, 0.0 表示按钮没有被按下,1.0 则表示按钮被完全按下。

+ +

语法

+ +
var pressState = navigator.getGamepads()[0].value;
+// 只读属性、双精浮点值
+
+ +

示例

+ +
var gp = navigator.getGamepads()[0];
+
+if(gp.buttons[0].value > 0) {
+  // 响应模拟按钮被按下
+} 
+ +

+ +

一个 {{domxref("double")}} (双精浮点值)。

+ +

规范

+ + + + + + + + + + + + + + +
规范状态备注
{{SpecName("Gamepad", "#widl-GamepadButton-value", "GamepadButton.value")}}{{Spec2("Gamepad")}}Initial definition
+ +

浏览器兼容性

+ +

{{Compat("api.GamepadButton.value")}}

+ +

另请参阅

+ +

使用 Gamepad API

-- cgit v1.2.3-54-g00ecf