Suppose I've prompted the user for input with readline ( in Node ).
Is it possible to access what he types before it's even entered?
Thanks in advance!
Suppose I've prompted the user for input with readline ( in Node ).
Is it possible to access what he types before it's even entered?
Thanks in advance!
Switch to the raw mode and you can get one by one when the user presses the key.
var stdin = process.openStdin();
require('tty').setRawMode(true);
stdin.on('keypress', function (chunk, key) {
process.stdout.write('Get Chunk: ' + chunk + '\n');
if (key && key.ctrl && key.name == 'c') process.exit();
});