web api instance method
HIDDevice: open() method
Secure contextLimited availabilityAvailable in workers
The open() method of the HIDDevice interface requests that the operating system opens the HID device.
[!NOTE] HID devices are not opened automatically. Therefore, a
HIDDevicereturned byrequestDevice()must be opened with this method before it is available to transfer data.
Syntax
open()
Parameters
None.
Return value
A Promise that resolves with undefined once the connection is opened.
Exceptions
InvalidStateErrorDOMException- : Thrown if the connection is already open.
NotAllowedErrorDOMException- : Thrown if the attempt to open the connection fails for any reason.
Examples
In the following example, we wait for the HID connection to open before attempting to send or receive data.
await device.open();
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.