aboutsummaryrefslogtreecommitdiff
path: root/files/fa/web/api/gamepadevent/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/fa/web/api/gamepadevent/index.html')
-rw-r--r--files/fa/web/api/gamepadevent/index.html64
1 files changed, 64 insertions, 0 deletions
diff --git a/files/fa/web/api/gamepadevent/index.html b/files/fa/web/api/gamepadevent/index.html
new file mode 100644
index 0000000000..292215959f
--- /dev/null
+++ b/files/fa/web/api/gamepadevent/index.html
@@ -0,0 +1,64 @@
+---
+title: GamepadEvent
+slug: Web/API/GamepadEvent
+translation_of: Web/API/GamepadEvent
+---
+<pre class="syntaxbox notranslate">{{APIRef("Gamepad API")}}</pre>
+
+<p>The GamepadEvent interface of the Gamepad API contains references to gamepads connected to the system, which is what the gamepad events {{domxref("Window.gamepadconnected")}} and {{domxref("Window.gamepaddisconnected")}} are fired in response to.</p>
+
+<h2 id="Constructor">Constructor</h2>
+
+<dl>
+ <dt>{{domxref("GamepadEvent.GamepadEvent","GamepadEvent()")}}</dt>
+ <dd>Returns a new <code>GamepadEvent</code> object.</dd>
+</dl>
+
+<h2 id="Properties">Properties</h2>
+
+<dl>
+ <dt>{{ domxref("GamepadEvent.gamepad") }} {{readonlyInline}}</dt>
+ <dd>Returns a {{ domxref("Gamepad") }} object, providing access to the associated gamepad data for the event fired.</dd>
+</dl>
+
+<h2 id="Examples">Examples</h2>
+
+<p>The gamepad property being called on a fired {{domxref("Window.gamepadconnected")}} event.</p>
+
+<pre class="brush: js notranslate">window.addEventListener("gamepadconnected", function(e) {
+ console.log("Gamepad connected at index %d: %s. %d buttons, %d axes.",
+ e.gamepad.index, e.gamepad.id,
+ e.gamepad.buttons.length, e.gamepad.axes.length);
+});</pre>
+
+<p>And on a {{domxref("Window.gamepaddisconnected")}} event.</p>
+
+<pre class="brush: js notranslate">window.addEventListener("gamepaddisconnected", function(e) {
+ console.log("Gamepad disconnected from index %d: %s",
+ e.gamepad.index, e.gamepad.id);
+});</pre>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName("Gamepad", "#gamepadevent-interface", "GamepadEvent")}}</td>
+ <td>{{Spec2("Gamepad")}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{Compat("api.GamepadEvent")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<p><a href="/en-US/docs/Web/Guide/API/Gamepad">Using the Gamepad API</a></p>