Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

keyboardevent-key-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keyboardevent-key-polyfill

polyfill for `KeyboardEvent.prototype.key`

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
37K
decreased by-21.01%
Maintainers
1
Weekly downloads
 
Created
Source

keyboardevent-key-polyfill

Polyfill for KeyboardEvent.prototype.key.

NOTE: All major browsers now support KeyboardEvent.prototype.key. Firefox already shipped with this for a while; recent versions of Edge, Chrome, and Safari also now have shipped support. This will still enable KeyboardEvent.prototype.key in environments where it may not yet be available.

Example

View Demo


Say goodbye to this:

document.addEventListener('keydown', function (e) {
  console.log('Code of key pressed:', e.which || e.keyCode);  // 39
});

And hello to this:

document.addEventListener('keydown', function (e) {
  console.log('Name of key pressed:', e.key);  // ArrowRight
});

Usage

From standalone script

Just drop the script on your page and call the polyfill method.

<script src="index.js"></script>
<script>keyboardeventKeyPolyfill.polyfill();</script>

If you're using AMD:

require('keyboardevent-key-polyfill').polyfill();

From npm (Node/Browserify/WebPack)

Install from npm:

npm install keyboardevent-key-polyfill

Then require the CommonJS module for use with Browserify/webpack:

require('keyboardevent-key-polyfill').polyfill();

License

All code and content within this source-code repository is licensed under the Creative Commons Zero v1.0 Universal license (CC0 1.0 Universal; Public Domain Dedication).

You can copy, modify, distribute and perform this work, even for commercial purposes, all without asking permission.

For more information, refer to these following links:

Keywords

FAQs

Package last updated on 07 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc