Diffdown is a real-time collaborative Markdown editor/previewer built on the AT Protocol diffdown.com
at main 18 lines 735 B view raw view rendered
1# W3C keyname 2 3Tiny library that exports a function `keyName` that takes a keyboard event and 4returns a 5[`KeyboardEvent.key`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)-style 6string. Will use the actual `key` property of the event if available, 7and fall back to a value synthesized from the `keyCode` otherwise. 8 9Probably often wrong on non-US keyboards, since the correspondence 10between a key code and the character it produces when shift is held is 11predicted based on a hard-coded table. Meant as a fallback for 12`KeyboardEvent.key`, not a replacement. 13 14The lookup tables from key codes (`event.keyCode`) to names are 15exported as `base` (when Shift isn't held) and `shift` (when Shift is 16held). 17 18License: MIT