Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sindresorhus/esc-exit
Exit the process when the `esc` key is pressed
https://github.com/sindresorhus/esc-exit
Last synced: about 1 month ago
JSON representation
Exit the process when the `esc` key is pressed
- Host: GitHub
- URL: https://github.com/sindresorhus/esc-exit
- Owner: sindresorhus
- License: mit
- Created: 2014-04-05T18:36:16.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2023-12-04T23:27:33.000Z (11 months ago)
- Last Synced: 2024-04-13T16:33:41.366Z (7 months ago)
- Language: JavaScript
- Size: 16.6 KB
- Stars: 57
- Watchers: 7
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
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.