0

I am trying to get a disconnect event from a USB HID device using the WebHID API.

The code:

const devices = await navigator.hid.requestDevice({

    filters: [{vendorId: 'some_vendor_id'}]
,
});

const device = devices[0];




console.log(`HID connected: ${device.productName}`);


if (!device.opened) {
    await device.open();

}



navigator.hid.addEventListener('disconnect', device => {

    console.log(`HID disconnected: ${device.productName}`);

});

Device connects successfully but after it is turned off or disconnected from computer, disconnect event is not triggered.

Am I doing something wrong or is it a bug?

1

1 Answer 1

1

These events are not yet implemented. I have filed an issue to help track this.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.