# onkeycode

> Execute function on key code

Latest version **0.2.0** (published 2016-10-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install onkeycode
pnpm add onkeycode
yarn add onkeycode
bun add onkeycode
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2016-10-02 |
| First published | 2016-10-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Olvier |
| Maintainers | bredele |
| Keywords | key, event, keyboard |

## Links

- npm: https://www.npmjs.com/package/onkeycode
- Repository: https://github.com/bredele/onkeycode
- Homepage: https://github.com/bredele/onkeycode#readme
- Issues: https://github.com/bredele/onkeycode/issues
- npm.io page: https://npm.io/package/onkeycode

## 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

- 0.2.0 (latest) — 2016-10-02
- 0.1.0 — 2016-10-02

## README

# onkeycode

Execute function on key code event.

## Usage

```js
document.body.addEventListener = onkeycode('esc', function(e) {
  // do something on escape
});
```

## Keys

The following keys are supported by this module:
  - tab
  - enter
  - backspace
  - shift
  - ctrl
  - alt
  - break
  - caps
  - esc
  - space
  - left
  - up
  - right
  - down
  - delete
  - command

All other keys can be use with their id:

```js
document.body.addEventListener = onkeycode(36, function(e) {
  // do something on home pressed
});
```


## License

MIT License

Copyright (c) 2016 Olivier Wietrich

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

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