Window.ongamepadconnected

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The ongamepadconnected property of the Window interface represents an event handler that will run when a gamepad is connected (when the gamepadconnected event fires).

The event object is of type GamepadEvent.

Syntax

window.ongamepadconnected = function() { ... };

Examples

window.ongamepadconnected = function(event) {
  // All buttons and axes values can be accessed through
  event.gamepad;
};

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
ongamepadconnected
35
21-35
≤18
29
No
22
15-22
10.1
No
35
25-35
32
22
14-22
No
3.0
1.5-3.0
secure_context_required
86
86
91
No
72
No
No
86
91
61
No
No

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Window/ongamepadconnected