Exit the process when the `esc` key is pressed
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.editorconfig tweaks Aug 13, 2014
.gitattributes init Apr 5, 2014
.gitignore init Apr 5, 2014
.jshintrc tweaks Aug 13, 2014
.travis.yml Update .travis.yml Feb 8, 2015
index.js don't unref stdin May 25, 2014
license tweaks Aug 13, 2014
package.json 1.0.0 Aug 13, 2014
readme.md tweaks Aug 13, 2014
test-done.js minor tweak Sep 5, 2014
test.js tweaks Aug 13, 2014


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.


$ npm install --save esc-exit


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



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.


MIT © Sindre Sorhus