web api instance method
HID: getDevices() method
Secure contextLimited availabilityAvailable in workers
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
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.