thegecko / webusb

Node.js implementation of the WebUSB Specification
https://thegecko.github.io/webusb/
MIT License
183 stars 27 forks source link

Can this api be used to detect USB plug/unplug? #72

Closed samhuang1111 closed 4 years ago

samhuang1111 commented 4 years ago

Can this api be used to detect USB plug/unplug?

thegecko commented 4 years ago

Yes, it follows the WebUSB spec which outlines onconnect and ondisconnect` events:

https://github.com/thegecko/webusb/blob/183e468bb5b9f6e899636c434d7aee689c8511fe/examples/url.js#L45

However, if you just want to detect usb devices in node and don't need it to look like WebUSB, I'd recommend using the node-usb or usb-detection libraries.