Skip to content

shvaikalesh/shim-keyboard-event-key

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

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

About

Tiny KeyboardEvent#key shim for IE and MS Edge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published