0b0707145b
* refactor: replace `.forEach()` with `for-of` * refactor docs/fiddles/features/web-hid/renderer.js
10 lines
430 B
JavaScript
10 lines
430 B
JavaScript
function formatDevices (devices) {
|
|
return devices.map(device => device.productName).join('<hr>')
|
|
}
|
|
|
|
async function testIt () {
|
|
document.getElementById('granted-devices').innerHTML = formatDevices(await navigator.hid.getDevices())
|
|
document.getElementById('granted-devices2').innerHTML = formatDevices(await navigator.hid.requestDevice({ filters: [] }))
|
|
}
|
|
|
|
document.getElementById('clickme').addEventListener('click', testIt)
|