node package manager
Painless code sharing. npm Orgs help your team discover, share, and reuse code. Create a free org »

esc-exit

esc-exit Build Status

Exit the process when the esc key is pressed

Useful for CLI tools to let the user press esc to get out.

Install

$ npm install --save esc-exit

Usage

var escExit = require('esc-exit');
 
escExit();

API

Using this prevents the process from exiting normally.

There are multiple ways you can handle this:

  • Call escExit.done() when you're done listening. It will then let the process exit normally.

  • Use process.stdin.unref() if you don't intend to use procces.stdin afterwards. It will let the process exit normally.

  • Call process.exit() to exit the process directly.

License

MIT © Sindre Sorhus