mirror of
https://github.com/google/mozc-devices.git
synced 2025-11-09 01:03:26 +03:00
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>
This commit is contained in:
29
mozc-doublesided/examples/webhid.html
Normal file
29
mozc-doublesided/examples/webhid.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user