aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/gamepadevent/gamepad/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/api/gamepadevent/gamepad/index.html')
-rw-r--r--files/zh-cn/web/api/gamepadevent/gamepad/index.html51
1 files changed, 51 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/gamepadevent/gamepad/index.html b/files/zh-cn/web/api/gamepadevent/gamepad/index.html
new file mode 100644
index 0000000000..98e2d27351
--- /dev/null
+++ b/files/zh-cn/web/api/gamepadevent/gamepad/index.html
@@ -0,0 +1,51 @@
+---
+title: GamepadEvent.gamepad
+slug: Web/API/GamepadEvent/gamepad
+translation_of: Web/API/GamepadEvent/gamepad
+---
+<div>{{APIRef("Gamepad API")}}</div>
+
+<p><strong>{{domxref("GamepadEvent")}} interface </strong>的 <code><strong>GamepadEvent.gamepad</strong></code> 属性返回一个 {{domxref("Gamepad")}} 对象,为触发 {{event("gamepadconnected")}} 和{{event("gamepaddisconnected")}} 事件提供相关联控制器数据的访问。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">只读 属性 Gamepad gamepad;</pre>
+
+<h2 id="示例">示例</h2>
+
+<p>在触发的 {{domxref("Window.gamepadconnected")}} 事件上调用 <code>gamepad</code> 属性。</p>
+
+<pre class="brush: js">window.addEventListener("gamepadconnected", function(e) {
+ console.log("控制器已连接于 %d 位:%s. %d 个按钮, %d 个坐标方向。",
+ e.gamepad.index, e.gamepad.id,
+ e.gamepad.buttons.length, e.gamepad.axes.length);
+});</pre>
+
+<h2 id="值">值</h2>
+
+<p>一个 {{domxref("Gamepad")}} 对象。</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-GamepadEvent-gamepad", "GamepadEvent.gamepad")}}</td>
+ <td>{{Spec2("Gamepad")}}</td>
+ <td>初始定义</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("api.GamepadEvent.gamepad")}}</p>
+
+<h2 id="另请参阅">另请参阅</h2>
+
+<p><a href="/en-US/docs/Web/Guide/API/Gamepad">使用 Gamepad API</a></p>