# keyboardevent-key-polyfill

> polyfill for `KeyboardEvent.prototype.key`

Latest version **1.1.0** (published 2017-04-07) · CC0-1.0 license · 0 weekly downloads

## Install

```sh
npm install keyboardevent-key-polyfill
pnpm add keyboardevent-key-polyfill
yarn add keyboardevent-key-polyfill
bun add keyboardevent-key-polyfill
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2017-04-07 |
| First published | 2015-12-23 |
| Weekly downloads | 0 |
| License | CC0-1.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 48 |
| Author | Chris Van |
| Maintainers | cvan |
| Keywords | polyfill, event, keyboard, keyboard-event, key, key-event, client-side, browser |

## Links

- npm: https://www.npmjs.com/package/keyboardevent-key-polyfill
- Repository: https://github.com/cvan/keyboardevent-key-polyfill
- Homepage: https://github.com/cvan/keyboardevent-key-polyfill/
- Issues: https://github.com/cvan/keyboardevent-key-polyfill/issues
- npm.io page: https://npm.io/package/keyboardevent-key-polyfill

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2017-04-07
- 1.0.2 — 2016-04-08
- 1.0.1 — 2015-12-23

## README

# keyboardevent-key-polyfill

Polyfill for `KeyboardEvent.prototype.key`.

> **NOTE:** All major browsers [now support `KeyboardEvent.prototype.key`](http://caniuse.com/#feat=keyboardevent-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](https://cvan.io/keyboardevent-key-polyfill/)__

<hr>

Say goodbye to this:

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

And hello to this:

```js
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.

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

If you're using AMD:

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

### From npm (Node/Browserify/WebPack)

Install from [npm](https://www.npmjs.com/package/keyboardevent-key-polyfill):

```bash
npm install keyboardevent-key-polyfill
```

Then require the CommonJS module for use with [Browserify](http://browserify.org)/[webpack](https://webpack.js.org/):

```js
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)](LICENSE.md).

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:

* a copy of the [license](LICENSE.md) in [this source-code repository](https://github.com/cvan/keyboardevent-key-polyfill)
* the [human-readable summary](https://creativecommons.org/publicdomain/zero/1.0/) of the [full text of the legal code](https://creativecommons.org/publicdomain/zero/1.0/legalcode)
* the [full text of the legal code](https://creativecommons.org/publicdomain/zero/1.0/legalcode)

---
_Source: https://npm.io/package/keyboardevent-key-polyfill · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
