Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sindresorhus/esc-exit

Exit the process when the `esc` key is pressed
https://github.com/sindresorhus/esc-exit

Last synced: about 2 months ago
JSON representation

Exit the process when the `esc` key is pressed

Awesome Lists containing this project

README

        

# esc-exit

> Exit the process when the esc key is pressed

Useful for CLI tools to let the user press esc or control+c to get out.

## Install

```sh
npm install esc-exit
```

## Usage

```js
import escExit from 'esc-exit';

escExit();
```

## API

Using this prevents the process from exiting normally.

There are multiple ways you can handle this:

- Call the unsubscribe method that `escExit()` returns when you're done listening. It will then let the process exit normally.

- Call `process.exit()` to exit the process directly.