这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
Navigator.getGamepads()
method returns an array of
Gamepad
objects, one for each gamepad connected to the device.
Elements in the array may be
null
if a gamepad disconnects during a session, so that the remaining gamepads retain the same index.
var gamepads = navigator.getGamepads();
window.addEventListener("gamepadconnected", function(e) {
var gp = navigator.getGamepads()[e.gamepad.index];
console.log(
"Gamepad connected at index %d: %s. %d buttons, %d axes.",
gp.index, gp.id, gp.buttons.length, gp.axes.length
);
});
| 规范 | 状态 | 注释 |
|---|---|---|
|
Gamepad
The definition of 'The Gamepad API specification' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
getGamepads
|
Chrome
35
|
Edge 12 | Firefox 29 | IE No |
Opera
22
|
Safari No |
WebView Android
37
|
Chrome Android
35
|
Firefox Android No |
Opera Android
22
|
Safari iOS No |
Samsung Internet Android
3.0
|
完整支持
不支持
实验。期望将来行为有所改变。
要求使用供应商前缀或不同名称。
Navigator
activeVRDisplays
appCodeName
appName
appVersion
battery
buildID
clipboard
connection
cookieEnabled
credentials
deviceMemory
doNotTrack
geolocation
keyboard
语言
languages
locks
maxTouchPoints
mediaDevices
mediaSession
onLine
oscpu
permissions
platform
product
productSub
serviceWorker
userAgent
vendor
vendorSub
webdriver
xr