È possibile ascoltare le sequenze di tasti in arrivo in uno script nodejs in esecuzione? Se uso process.openStdin()e ascolto il suo 'data'evento, l'input viene bufferizzato fino alla nuova riga successiva, in questo modo:
// stdin_test.js
var stdin = process.openStdin();
stdin.on('data', function(chunk) { console.log("Got chunk: " + chunk); });
Eseguendo questo, ottengo:
$ node stdin_test.js
<-- type '1'
<-- type '2'
<-- hit enter
Got chunk: 12
Quello che mi piacerebbe è vedere:
$ node stdin_test.js
<-- type '1' (without hitting enter yet)
Got chunk: 1
Sto cercando un nodejs equivalente, ad esempio, getcin ruby
È possibile?