# @derhuerst/cli-on-key

> Read command line key presses from process.stdin.

Latest version **0.1.0** (published 2018-03-31) · ISC license · 0 weekly downloads

## Install

```sh
npm install @derhuerst/cli-on-key
pnpm add @derhuerst/cli-on-key
yarn add @derhuerst/cli-on-key
bun add @derhuerst/cli-on-key
```

## Health

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

Positive: has types package; no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2018-03-31 |
| First published | 2018-03-31 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/derhuerst__cli-on-key) |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 0 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Jannis R |
| Maintainers | derhuerst |
| Keywords | command line, cli, key, keypress, stdin, event |

## Links

- npm: https://www.npmjs.com/package/@derhuerst/cli-on-key
- Repository: https://github.com/derhuerst/cli-on-key
- Issues: https://github.com/derhuerst/cli-on-key/issues
- npm.io page: https://npm.io/package/@derhuerst/cli-on-key

## 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.0 (latest) — 2018-03-31

## README

# cli-on-key

**Read command line key presses from process.stdin.** Based on [`TooTallNate/keypress`](https://github.com/TooTallNate/keypress).

[![npm version](https://img.shields.io/npm/v/cli-on-key.svg)](https://www.npmjs.com/package/derhuerst/cli-on-key)
![ISC-licensed](https://img.shields.io/github/license/derhuerst/cli-on-key.svg)
[![chat with me on Gitter](https://img.shields.io/badge/chat%20with%20me-on%20gitter-512e92.svg)](https://gitter.im/derhuerst)
[![support me on Patreon](https://img.shields.io/badge/support%20me-on%20patreon-fa7664.svg)](https://patreon.com/derhuerst)


## Installing

```shell
npm install @derhuerst/cli-on-key
```


## Usage

`listen` will switch the stream to [raw mode](https://nodejs.org/api/tty.html#tty_readstream_israw), `stopListening` will revert to the previous value.

```js
const listen = require('cli-on-key')

const stopListening = listen(process.stdin, (key) => {
	if (key.ctrl && key.name === 'c') {
		stopListening() // stop on Ctrl + C
	} else console.log(key)
})
```


## Contributing

If you have a question or have difficulties using `cli-on-key`, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to [the issues page](https://github.com/derhuerst/cli-on-key/issues).

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