How to read data input from keyboard with NodeJS?

2

I am trying to read the data entry from keyboard in NodeJS, I would like to know how to do this in the way that java has its scanner or c ++ has something similar, I hope to give you to understand.

    
asked by Acnologia 04.02.2018 в 23:53
source

1 answer

1

Nodejs natively provides the openStdin() function to accept keyboard entries, here's an example:

console.log("Escribe tu nombre");
var stdin = process.openStdin();

stdin.addListener("data", function(d) {
    console.log("Tu nombre es: " + 
        d.toString().trim());
  });
    
answered by 05.02.2018 / 00:06
source