Node.js 在提示节点JS后访问用户输入

Node.js 在提示节点JS后访问用户输入,node.js,readline,Node.js,Readline,假设我用readline(在节点中)提示用户输入 有可能在他输入之前就访问他输入的内容吗 提前谢谢 切换到原始模式,当用户按键时,您可以逐个获取 var stdin = process.openStdin(); require('tty').setRawMode(true); stdin.on('keypress', function (chunk, key) { process.stdout.write('Get Chunk: ' + chunk + '\n'); if (

假设我用readline(在节点中)提示用户输入

有可能在他输入之前就访问他输入的内容吗


提前谢谢

切换到原始模式,当用户按键时,您可以逐个获取

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();
});

这回答了你的问题吗?