# terminal-keypress

> Returns keypress events while enabling default input behavior

Latest version **0.4.4** (published 2017-02-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install terminal-keypress
pnpm add terminal-keypress
yarn add terminal-keypress
bun add terminal-keypress
```

## 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.4.4 |
| Published | 2017-02-06 |
| First published | 2016-11-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Scott McKenzie |
| Maintainers | slammayjammay |
| Keywords | terminal, node, input, output, keypress |

## Links

- npm: https://www.npmjs.com/package/terminal-keypress
- Repository: https://github.com/slammayjammay/terminal-keypress
- Homepage: https://github.com/slammayjammay/terminal-keypress#readme
- Issues: https://github.com/slammayjammay/terminal-keypress/issues
- npm.io page: https://npm.io/package/terminal-keypress

## Dependencies (5)

- [chalk](https://npm.io/package/chalk.md) ^1.1.3
- [strip-ansi](https://npm.io/package/strip-ansi.md) ^3.0.1
- [ansi-escapes](https://npm.io/package/ansi-escapes.md) ^1.4.0
- [babel-polyfill](https://npm.io/package/babel-polyfill.md) ^6.20.0
- [@patrickkettner/get-cursor-position](https://npm.io/package/@patrickkettner/get-cursor-position.md) ^1.0.4

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.4.4 (latest) — 2017-02-06
- 0.4.3 — 2017-01-18
- 0.4.2 — 2017-01-18
- 0.4.1 — 2017-01-18
- 0.4.0 — 2017-01-18
- 0.3.3 — 2017-01-05
- 0.3.2 — 2016-12-20
- 0.3.1 — 2016-12-19
- 0.3.0 — 2016-12-16
- 0.2.0 — 2016-12-08
- 0.1.1 — 2016-11-23
- 0.1.0 — 2016-11-23

## README

# terminal-keypress
```shell
  $ npm install --save terminal-keypress
```

Fires keypress events for terminal applications. Unfortunately, this seems to be possible only via `process.stdin.setRawMode(true)`, which kills the default input behavior. `terminal-keypress` aims to fire keypress events while enabling
default input behavior.

# Usage
Require it:
```
  const keypress = require('terminal-keypress')
  // sets raw mode true and enables default behavior
  keypress.init()
```

Add callbacks for keypress events:
```
  keypress.on('keypress', (char, key) => {
    if (key.sequence === 'a') {
      console.log('You typed an "a"!')
    }
  })

  keypress.once('return', () => {
    let input = keypress.input()
    console.log(input)
  })
```

Easily color the user's input using chalk:
```
  const chalk = require('chalk')
  keypress.color(letter => chalk.red(letter))
```

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