mirror of
https://github.com/google/mozc-devices.git
synced 2025-11-09 01:03:26 +03:00
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>
29 lines
746 B
HTML
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> |