diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/gamepadbutton/pressed | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/gamepadbutton/pressed')
-rw-r--r-- | files/zh-cn/web/api/gamepadbutton/pressed/index.html | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/gamepadbutton/pressed/index.html b/files/zh-cn/web/api/gamepadbutton/pressed/index.html new file mode 100644 index 0000000000..9126b26ddb --- /dev/null +++ b/files/zh-cn/web/api/gamepadbutton/pressed/index.html @@ -0,0 +1,52 @@ +--- +title: GamepadButton.pressed +slug: Web/API/GamepadButton/pressed +translation_of: Web/API/GamepadButton/pressed +--- +<p>{{APIRef("Gamepad API")}}</p> + +<p>{{domxref("GamepadButton")}}接口下的 <code><strong>GamepadButton.pressed</strong></code> 属性返回一个表示按钮当然是被按下了 (<code>true</code>) 还是没有被按下 (<code>false</code>) 的布尔值。</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox"><span class="idlInterface" id="idl-def-GamepadButton"><span class="idlAttribute">var isPressed = navigator.getGamepads()[0].pressed; +</span></span></pre> + +<h2 id="示例">示例</h2> + +<pre class="brush: js">var gp = navigator.getGamepads()[0]; // 获取第一个控制器对象 + +if(gp.buttons[0].pressed == true) { + // 响应按钮按下 +}</pre> + +<h2 id="值">值</h2> + +<p>一个 {{domxref("boolean")}} (布尔值)。</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-pressed", "GamepadButton.pressed")}}</td> + <td>{{Spec2("Gamepad")}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p>{{Compat("api.GamepadButton.pressed")}}</p> + +<h2 id="另请参阅">另请参阅</h2> + +<ul> + <li><a href="/en-US/docs/Web/Guide/API/Gamepad">使用 Gamepad API</a></li> +</ul> |