MDN self-hosted library · e01.org

HIDDevice: open() method

WebHID APIwindowandworkerexceptshared

WebHID APIwindow_and_worker_except_shared

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 HIDDevice returned by HID.requestDevice() 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

  • InvalidStateError DOMException
  • : Thrown if the connection is already open.
  • NotAllowedError DOMException
  • : 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

Browser compatibility