Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

esc-exit

sindresorhus14.5kMIT3.0.1

Exit the process when the esc key is pressed

esc, exit, process, key, press, stdin, readline, event, escape, cli, tool

readme

esc-exit

Exit the process when the <kbd>esc</kbd> key is pressed

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

Install

npm install esc-exit

Usage

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.