--- title: Navigator.getGamepads() slug: Web/API/Navigator/getGamepads translation_of: Web/API/Navigator/getGamepads ---
{{APIRef("Gamepad API")}}{{SeeCompatTable}}
Navigator.getGamepads() метод, возвращающий массив {{ domxref("Gamepad") }} объектов, по одному для каждого геймпада, подключенному к устройству.
var arrayGP = navigator.getGamepads();
window.addEventListener("gamepadconnected", function(e) {
var gp = navigator.getGamepads()[0];
console.log("Gamepad connected at index %d: %s. %d buttons, %d axes.",
gp.index, gp.id,
gp.buttons.length, gp.axes.length);
});
| Спецификация | Статус | Комментарий |
|---|---|---|
| {{SpecName('Gamepad', '', 'The Gamepad API specification')}} | {{Spec2('Gamepad')}} | Initial definition. |
{{ CompatibilityTable() }}
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|
| General support |
21.0 {{ property_prefix("webkit") }} |
{{ CompatGeckoDesktop("29.0") }} [1] | {{ CompatNo() }} |
15.0 {{ property_prefix("webkit") }} |
{{ CompatNo() }} |
| Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| General support | {{ CompatNo() }} | {{ CompatNo() }} | {{ CompatNo() }} | {{ CompatNo() }} | {{ CompatNo() }} |
[1] Was available behind a preference since Firefox 24.