rl.write(data[, key])
data<string>key<Object>ctrl<boolean>true表示 Ctrl 键。
meta<boolean>true表示 Meta 键。shift<boolean>true表示 Shift 键。name<string> 键的名称。
rl.write() 方法将把 data 或由 key 标识的按键序列写入 output。只有当 output 是 文字电话 文本终端时,才支持 key 参数。有关按键组合的列表,请参见 TTY 键绑定。
【The rl.write() method will write either data or a key sequence identified
by key to the output. The key argument is supported only if output is
a TTY text terminal. See TTY keybindings for a list of key
combinations.】
如果指定了 key,data 将被忽略。
【If key is specified, data is ignored.】
当被调用时,rl.write() 将会恢复已暂停的 input 流。
【When called, rl.write() will resume the input stream if it has been
paused.】
如果 readline.Interface 是在将 output 设置为 null 或 undefined 的情况下创建的,则 data 和 key 不会被写入。
【If the readline.Interface was created with output set to null or
undefined the data and key are not written.】
rl.write('Delete this!');
// Simulate Ctrl+U to delete the line written previously
rl.write(null, { ctrl: true, name: 'u' }); rl.write() 方法会将数据写入 readline Interface 的 input,就好像是用户提供的一样。
【The rl.write() method will write the data to the readline Interface's
input as if it were provided by the user.】