# key-events

> Keyboard listener for browsers, using vkey.

Latest version **0.1.1** (published 2019-06-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install key-events
pnpm add key-events
yarn add key-events
bun add key-events
```

## 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.1.1 |
| Published | 2019-06-22 |
| First published | 2016-01-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | apexearth@gmail.com |
| Maintainers | apexearth |
| Keywords | keyboard, events, input |

## Links

- npm: https://www.npmjs.com/package/key-events
- Repository: https://github.com/apexearth/key-events
- Homepage: https://github.com/apexearth/key-events#readme
- Issues: https://github.com/apexearth/key-events/issues
- npm.io page: https://npm.io/package/key-events

## Dependencies (1)

- [vkey](https://npm.io/package/vkey.md) ^1.0.1

## 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.1.1 (latest) — 2019-06-22
- 0.1.0 — 2017-06-11
- 0.0.4 — 2016-01-19
- 0.0.3 — 2016-01-10
- 0.0.2 — 2016-01-10
- 0.0.1 — 2016-01-10

## README

# key-events

![](https://travis-ci.org/apexearth/key-events.svg)
![](http://img.shields.io/npm/v/key-events.svg?style=flat)
![](http://img.shields.io/npm/dm/key-events.svg?style=flat)
![](http://img.shields.io/npm/l/key-events.svg?style=flat)

Provides **keydown** and **keyup** events using [vkey](https://www.npmjs.com/package/vkey)
 to developers using Node.js to develop for browsers.
 
## Usage

[![NPM](https://nodei.co/npm/key-events.png)](https://nodei.co/npm/key-events/)

### `listener = keyevents([target], [events])`

## Examples

#### Basic Usage

    const keyevents = require('key-events') // Also at window.keyevents.

    // Default target is:  document.body
    // Default events are: ['keyup', 'keydown']
    var keys = keyevents() 
    
    keys.on("keydown", function(key, event) {
        console.log(key)   // A vkey value based on the key pressed.
        console.log(event) // The original event received.
    })    
    
    keys.on("keyup", function(key, event) {
        console.log(key)   // A vkey value based on the key pressed.
        console.log(event) // The original event received.
    })

#### Custom  Target

    var keys = window.keyevents(document) // Default target is `document.body`

#### Custom Event List

    var keys = window.keyevents(['keypress']) // Default target is `document.body`

    keys.on("keypress", function(key, event) {
        console.log(key)   // A vkey value based on the key pressed.
        console.log(event) // The original event received.
    })

#### Custom Target & Event List

    var keys = window.keyevents(document, ['keypress']) // Default target is `document.body`

    keys.on("keypress", function(key, event) {
        console.log(key)   // A vkey value based on the key pressed.
        console.log(event) // The original event received.
    })
    
## Tests

- Mocha
   - Test functionality in Node.js
- Karma
   - Using browserify, test functionality in browsers
- User Testing
   - [grunt user-test](Gruntfile.js) is set to build, serve, and open [test/index.html](test/index.html)

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