Exit the process when `Ctrl`+`C` is pressed
npm install ctrlc-exit> Exit the process when Ctrl+C is pressed
Useful for CLI tools when default behavior to exit is disabled (e.g. raw mode is enabled).
```
$ npm install ctrlc-exit
`js
const ctrlcExit = require('ctrlc-exit');
ctrlcExit();
`
Using this prevents the process from exiting normally.
There are multiple ways you can handle this:
- Call ctrlcExit.done() when you're done listening. It will then let the process exit normally.process.stdin.unref()
- Use if you don't intend to use process.stdin afterwards. It will let the process exit normally.process.exit()` to exit the process directly.
- Call
- esc-exit - Exit the process using Esc.
MIT © Vadim Demedes