这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

ongamepadconnected 特性为 Window interface represents an event handler that will run when a gamepad is connected (when the gamepadconnected 事件激发)。

The event object is of type GamepadEvent .

句法

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

范例

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

规范

规范 状态 注释
Gamepad
The definition of 'gamepadconnected event' in that specification.
工作草案 初始定义

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
ongamepadconnected Chrome 35
35
不支持 21 — 35 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge ≤18 Firefox 29 IE No Opera 22
22
不支持 15 — 22 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari 10.1 WebView Android 37 Chrome Android 35
35
不支持 25 — 35 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 32 Opera Android 22
22
不支持 14 — 22 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari iOS No Samsung Internet Android 3.0
3.0
不支持 1.5 — 3.0 Prefixed
Prefixed Implemented with the vendor prefix: webkit

图例

完整支持

完整支持

不支持

不支持

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

另请参阅

元数据

  • 最后修改:
  1. 手柄 API
  2. 指南
    1. Using the Gamepad API
    2. Implementing controls using the Gamepad API
  3. 接口
    1. Gamepad
    2. GamepadButton
    3. GamepadEvent
  4. 特性
    1. Window.ongamepadconnected
    2. Window.ongamepaddisconnected
  5. 方法
    1. Navigator.getGamepads()
  6. 事件
    1. Window : gamepadconnected
    2. Window : gamepaddisconnected

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1