Debian Codegraph @

fixtures/keys.html

raw
1 <html>
2 <body style="font-family: monospace"></body>
3 <script>
4 let rec = (name) => (e) => {
5 let list = []
6 e.ctrlKey ? list.push('ctrl') : 0
7 e.altKey ? list.push('alt') : 0
8 e.shiftKey ? list.push('shift') : 0
9 e.metaKey ? list.push('meta') : 0
10 document.body.innerText += `${name} ${JSON.stringify(e.key)} ${e.code} ${
11 e.keyCode
12 } modifiers(${list.join(',')})\n`
13 }
14
15 window.onkeydown = rec('↓')
16 window.onkeyup = rec('↑')
17 </script>
18 </html>