Files
mozc-devices/mozc-doublesided/examples/webhid.html
Takashi Toyoshima 65db5df370 Add mozc double sided version.
Change-Id: I3c50b5c3435c3c01c79bfc14c5d605701a423356
Co-authored-by: Takashi Toyoshima <toyoshim@google.com>
Co-authored-by: Shun Ikejima <ikejima@google.com>
Reviewed-by: Eliot Courtney <edcourtney@google.com>
2024-10-08 12:30:10 +09:00

29 lines
746 B
HTML

<html>
<button onclick="connect()">キーボードを接続</button>
<hr>
<textarea id="text"></textarea>
<script>
async function connect() {
const [device] = await navigator.hid.requestDevice({
'filters': [
{ 'vendorId': 1155, 'productId': 22352 }]
});
// May fail to open common HID devices on macOS.
await device.open();
device.addEventListener("inputreport", e => {
const view = new Uint16Array(e.data.buffer);
const codepoint = [];
for (code of view) {
if (code) {
codepoint.push(code);
} else {
break;
}
}
document.getElementById('text').value +=
String.fromCodePoint.apply(null, codepoint);
});
}
</script>
</html>