MDN self-hosted library · e01.org
Web / API / HID

HID: getDevices() method

WebHID APIwindowandworkerexceptshared

WebHID APIwindow_and_worker_except_shared

The getDevices() method of the HID interface gets a list of connected HID devices that the user has previously been granted access to in response to a requestDevice() call.

Syntax

getDevices()

Parameters

None.

Return value

A Promise that resolves with a list of HIDDevice objects.

Examples

The following example gets a list of devices and logs the device names to the console.

let devices = await navigator.hid.getDevices();
devices.forEach((device) => {
  console.log(`HID: ${device.productName}`);
});

Specifications

Browser compatibility