Is it possible to listen for incoming keystrokes in a running nodejs script? If I use process.openStdin() and listen to its \'data\' event then the
process.openStdin()
\'data\'
In node >= v6.1.0:
const readline = require('readline'); readline.emitKeypressEvents(process.stdin); process.stdin.setRawMode(true); process.stdin.on('keypress', (str, key) => { console.log(str) console.log(key) })
See https://github.com/nodejs/node/issues/6626