@derhuerst/cli-on-key
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/derhuerst__cli-on-key package

0.1.0 • Public • Published

cli-on-key

Read command line key presses from process.stdin. Based on TooTallNate/keypress.

npm version build status ISC-licensed chat with me on Gitter support me on Patreon

Installing

npm install @derhuerst/cli-on-key

Usage

listen will switch the stream to raw mode, stopListening will revert to the previous value.

const listen = require('cli-on-key')

const stopListening = listen(process.stdin, (key) => {
	if (key.ctrl && key.name === 'c') {
		stopListening() // stop on Ctrl + C
	} else console.log(key)
})

Contributing

If you have a question or have difficulties using cli-on-key, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.

Package Sidebar

Install

npm i @derhuerst/cli-on-key

Weekly Downloads

36

Version

0.1.0

License

ISC

Unpacked Size

9.47 kB

Total Files

4

Last publish

Collaborators

  • derhuerst