aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/gamepadbutton/value
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/gamepadbutton/value
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/gamepadbutton/value')
-rw-r--r--files/zh-cn/web/api/gamepadbutton/value/index.html53
1 files changed, 53 insertions, 0 deletions
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
+---
+<p>{{APIRef("Gamepad API")}}</p>
+
+<p>{{domxref("GamepadButton")}}接口下的 <code><strong>GamepadButton.value</strong></code> 属性返回一个双精浮点值来表示许多现代控制器上的模拟按钮的状态,比如说扳机键。</p>
+
+<p>其值被规范于范围 <code>0.0</code> — <code>1.0</code> 内, <code>0.0</code> 表示按钮没有被按下,<code>1.0</code> 则表示按钮被完全按下。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="brush: js"><span class="idlInterface" id="idl-def-GamepadButton"><span class="idlAttribute">var pressState = navigator.getGamepads()[0].value;
+// 只读属性、双精浮点值</span></span>
+</pre>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: js">var gp = navigator.getGamepads()[0];
+
+if(gp.buttons[0].value &gt; 0) {
+ // 响应模拟按钮被按下
+} </pre>
+
+<h2 id="值">值</h2>
+
+<p>一个 {{domxref("double")}} (双精浮点值)。</p>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">备注</th>
+ </tr>
+ <tr>
+ <td>{{SpecName("Gamepad", "#widl-GamepadButton-value", "GamepadButton.value")}}</td>
+ <td>{{Spec2("Gamepad")}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("api.GamepadButton.value")}}</p>
+
+<h2 id="另请参阅">另请参阅</h2>
+
+<p><a href="/en-US/docs/Web/Guide/API/Gamepad">使用 Gamepad API</a></p>