# readkey

> A simple node key listener to read keys pressed on keyboard.

Latest version **1.0.0** (published 2018-12-30) · ISC license · 0 weekly downloads

## Install

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

## 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.0.0 |
| Published | 2018-12-30 |
| First published | 2018-12-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Jordi Martí |
| Maintainers | heedrox |
| Keywords | keypress, key, read, node, keyread, onkeypress |

## Links

- npm: https://www.npmjs.com/package/readkey
- Repository: https://github.com/jmarti-theinit/readkey
- Homepage: https://github.com/jmarti-theinit/readkey#readme
- Issues: https://github.com/jmarti-theinit/readkey/issues
- npm.io page: https://npm.io/package/readkey

## Alternatives

- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads
- [@1selfworld/adchain-sdk-react-native](https://npm.io/package/@1selfworld/adchain-sdk-react-native.md) — 80 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2018-12-30

## README

# readkey

A simple node key listener to read keys pressed on keyboard.

# Usage

Create a config object with:
- fn: the function that evaluates if the key has been pressed.
- command: the command executed if fn() returns true

Send it to readkey();

```
const readkey = require('readkey');
const keyCommands = [
  { fn: (str, key) => str === 'p', command: () => console.log('p was pressed') },
  { fn: (str, key) => key.ctrl && key.name === 'c', command: () => process.exit() },
  { fn: (str, key) => key.name === 'q', command: () => process.exit() },
];
readkey(keyCommands);
```

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