Tiny KeyboardEvent#key shim for IE and MS Edge
Switch branches/tags
Nothing to show
Clone or download
Permalink
Failed to load latest commit information.
README.md fix code block rendering on npm Feb 17, 2018
index.js add index.js Jul 20, 2017
package.json fix code block rendering on npm Feb 17, 2018

README.md

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
  }
})