UNPKG

exit-on-esc

Version:

A small debug library to print a buffer's content as a hex table

16 lines (13 loc) 340 B
const readline = require('readline'); // make sure that key events get forwarded. readline.emitKeypressEvents(process.stdin); if (process.stdin.isTTY) { process.stdin.setRawMode(true); } module.exports = () => { process.stdin.on('keypress', (str, key) => { if (key && key.name === 'escape') { process.exit(); } }); };