shim-keyboard-event-key

1.0.3 • Public • Published

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

Package Sidebar

Install

npm i shim-keyboard-event-key

Weekly Downloads

10,966

Version

1.0.3

License

MIT

Unpacked Size

2.12 kB

Total Files

3

Last publish

Collaborators

  • shvaikalesh