gamepadconnected

  • Revision slug: Web/Reference/Events/gamepadconnected
  • Revision title: gamepadconnected
  • Revision id: 403035
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment Moved From DOM/Mozilla_event_reference/gamepadconnected to Web/Reference/Events/gamepadconnected

Revision Content

The gampadconnected event is fired when the browser detects that a gamepad has been connected or the first time a buttuon/axis of the gamepad is used.

General info

Specification
Gamepad
Interface
Event
Bubbles
No
Cancelable
No
Target
DefaultView (<window>)
Default Action
None

Properties

{{OpenEventProperties()}}{{GamepadEventProperties()}}{{CloseEventProperties()}}

Example

// Note that the API is still vendor-prefixed in browsers implementing it
window.addEventListener("gamepadconnected", function( event ) {

    // All buttons and axes values can be accessed through
    event.gampad;

});

See also

Revision Source

<p>The <code>gampadconnected</code> event is fired when the browser detects that a gamepad has been connected or the first time a buttuon/axis of the gamepad is used.</p>
<h2 id="General_info">General info</h2>
<dl>
  <dt style="clear: left; float: left; text-align: right; width: 120px;">
    Specification</dt>
  <dd style="margin: 0 0 0 120px;">
    <a class="external" href="http://www.w3.org/TR/gamepad/#the-gamepadconnected-event">Gamepad</a></dd>
  <dt style="clear: left; float: left; text-align: right; width: 120px;">
    Interface</dt>
  <dd style="margin: 0 0 0 120px;">
    Event</dd>
  <dt style="clear: left; float: left; text-align: right; width: 120px;">
    Bubbles</dt>
  <dd style="margin: 0 0 0 120px;">
    No</dd>
  <dt style="clear: left; float: left; text-align: right; width: 120px;">
    Cancelable</dt>
  <dd style="margin: 0 0 0 120px;">
    No</dd>
  <dt style="clear: left; float: left; text-align: right; width: 120px;">
    Target</dt>
  <dd style="margin: 0 0 0 120px;">
    DefaultView (<code>&lt;window&gt;</code>)</dd>
  <dt style="clear: left; float: left; text-align: right; width: 120px;">
    Default Action</dt>
  <dd style="margin: 0 0 0 120px;">
    None</dd>
</dl>
<h2 id="Properties">Properties</h2>
<p>{{OpenEventProperties()}}{{GamepadEventProperties()}}{{CloseEventProperties()}}</p>
<h2 id="Example">Example</h2>
<pre class="brush:js;">
// Note that the API is still vendor-prefixed in browsers implementing it
window.addEventListener("gamepadconnected", function( event ) {

    // All buttons and axes values can be accessed through
    event.gampad;

});
</pre>
<h2 id="Related_Events">Related Events</h2>
<ul>
  <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla_event_reference/gamepaddisconnected">gamepaddisconnected</a></li>
</ul>
<h2 id="See_also">See also</h2>
<ul>
  <li><a href="/en-US/docs/API/Gamepad/Using_Gamepad_API">Using Gamepad API</a></li>
</ul>
Revert to this revision