JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3806514
  • Score
    100M100P100Q213231F
  • License MIT

Get a KeyboardEvent.key-style string from an event

Package Exports

  • w3c-keyname

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (w3c-keyname) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

W3C keyname

Tiny library that exports a function keyName that takes a keyboard event and returns a KeyboardEvent.key-style string. Will use the actual key property of the event if available, and fall back to a value synthesized from the keyCode otherwise.

Probably often wrong on non-US keyboards, since the correspondence between a key code and the character it produces when shift is held is predicted based on a hard-coded table. Meant as a fallback for KeyboardEvent.key, not a replacement.

The lookup tables from key codes (event.keyCode) to names are exported as base (when Shift isn't held) and shift (when Shift is held).

License: MIT