<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>WebHID Example</title>
</head>
<body>
<h1>WebHID Example</h1>
<button id = 'requestDevice' >Open Device</button>
<button id = 'openButton'>Open button</button>
<div id="device-info"></div>
<div id="output"></div>
<script>
let device;
requestDevice.onclick = async event => {
document.body.style.display = "none";
try {
const filters = [
{
vendorId: 0x03F0, productId: 0x034A //keyboard
}
];
[device] = await navigator.hid.requestDevice({ filters });
if (!device) return;
console.log(device);
} finally {
document.body.style.display = "";
}
};
openButton.onclick = async event => {
await device.open();
device.oninputreport = ({device, reportId, data}) => {
console.log(`Input report ${reportId} from ${device.productName}:`,
new Uint8Array(data.buffer));
};
};
</script>
</body>
</html>
this is my javascript code When I Choose keyboard hid device and try to press any button, oninputreport listener is not work
thanks for your help!
i want to try how could hid device listener work, thanks!
The datastruct is below
Keyboard input events are on the WebHID blocklist and so will not generate
inputreport
events.