JSPM

shim-keyboard-event-key

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

Tiny KeyboardEvent#key shim for IE and MS Edge

Package Exports

  • shim-keyboard-event-key

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 (shim-keyboard-event-key) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

shim-keyboard-event-key

Tiny KeyboardEvent#key shim for IE and MS Edge.

Up and running

Get the package from npm:

npm install shim-keyboard-event-key --save

And simply require the module:

import "shim-keyboard-event-key"

Otherwise, plug it the old-fashioned way:

<script src="https://unpkg.com/shim-keyboard-event-key" async></script>

Example

document.addEventListener("keyup", event => {
  if (event.defaultPrevented) return

  switch (event.key) {
    case "ArrowLeft":
    case "PageUp":
      player.prev()
      break

    case "ArrowRight":
    case "PageDown":
      player.next()
      break
  }
})