From b78294dc0041d2277ab904c35b56c0163bccdaab Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 18 Oct 2020 06:52:55 -0700 Subject: [PATCH] doc: use kbd element in readline doc PR-URL: https://github.com/nodejs/node/pull/35698 Reviewed-By: Daijiro Wachi Reviewed-By: Luigi Pinca --- doc/api/readline.md | 94 +++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/doc/api/readline.md b/doc/api/readline.md index d572eb4bb29f9b..13b93a283167be 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -59,9 +59,11 @@ The `'close'` event is emitted when one of the following occur: * The `rl.close()` method is called and the `readline.Interface` instance has relinquished control over the `input` and `output` streams; * The `input` stream receives its `'end'` event; -* The `input` stream receives `-D` to signal end-of-transmission (EOT); -* The `input` stream receives `-C` to signal `SIGINT` and there is no - `'SIGINT'` event listener registered on the `readline.Interface` instance. +* The `input` stream receives Ctrl+D to signal + end-of-transmission (EOT); +* The `input` stream receives Ctrl+C to signal `SIGINT` + and there is no `'SIGINT'` event listener registered on the + `readline.Interface` instance. The listener function is called without passing any arguments. @@ -126,8 +128,8 @@ added: v0.7.5 --> The `'SIGCONT'` event is emitted when a Node.js process previously moved into -the background using `-Z` (i.e. `SIGTSTP`) is then brought back to the -foreground using fg(1p). +the background using Ctrl+Z (i.e. `SIGTSTP`) is then +brought back to the foreground using fg(1p). If the `input` stream was paused *before* the `SIGTSTP` request, this event will not be emitted. @@ -149,9 +151,9 @@ added: v0.3.0 --> The `'SIGINT'` event is emitted whenever the `input` stream receives a -`-C` input, known typically as `SIGINT`. If there are no `'SIGINT'` event -listeners registered when the `input` stream receives a `SIGINT`, the `'pause'` -event will be emitted. +Ctrl+C input, known typically as `SIGINT`. If there are no `'SIGINT'` +event listeners registered when the `input` stream receives a `SIGINT`, the +`'pause'` event will be emitted. The listener function is invoked without passing any arguments. @@ -168,10 +170,10 @@ rl.on('SIGINT', () => { added: v0.7.5 --> -The `'SIGTSTP'` event is emitted when the `input` stream receives a `-Z` -input, typically known as `SIGTSTP`. If there are no `'SIGTSTP'` event listeners -registered when the `input` stream receives a `SIGTSTP`, the Node.js process -will be sent to the background. +The `'SIGTSTP'` event is emitted when the `input` stream receives a +Ctrl+Z input, typically known as `SIGTSTP`. If there are +no `'SIGTSTP'` event listeners registered when the `input` stream receives a +`SIGTSTP`, the Node.js process will be sent to the background. When the program is resumed using fg(1p), the `'pause'` and `'SIGCONT'` events will be emitted. These can be used to resume the `input` stream. @@ -288,9 +290,9 @@ added: v0.1.98 * `data` {string} * `key` {Object} - * `ctrl` {boolean} `true` to indicate the `` key. - * `meta` {boolean} `true` to indicate the `` key. - * `shift` {boolean} `true` to indicate the `` key. + * `ctrl` {boolean} `true` to indicate the Ctrl key. + * `meta` {boolean} `true` to indicate the Meta key. + * `shift` {boolean} `true` to indicate the Shift key. * `name` {string} The name of the a key. The `rl.write()` method will write either `data` or a key sequence identified @@ -308,7 +310,7 @@ If the `readline.Interface` was created with `output` set to `null` or ```js rl.write('Delete this!'); -// Simulate Ctrl+u to delete the line written previously +// Simulate Ctrl+U to delete the line written previously rl.write(null, { ctrl: true, name: 'u' }); ``` @@ -751,117 +753,117 @@ const { createInterface } = require('readline'); Notes - ctrl + shift + backspace + Ctrl+Shift+Backspace Delete line left Doesn't work on Linux, Mac and Windows - ctrl + shift + delete + Ctrl+Shift+Delete Delete line right Doesn't work on Mac - ctrl + c + Ctrl+C Emit SIGINT or close the readline instance - ctrl + h + Ctrl+H Delete left - ctrl + d + Ctrl+D Delete right or close the readline instance in case the current line is empty / EOF Doesn't work on Windows - ctrl + u + Ctrl+U Delete from the current position to the line start - ctrl + k + Ctrl+K Delete from the current position to the end of line - ctrl + a + Ctrl+A Go to start of line - ctrl + e + Ctrl+E Go to to end of line - ctrl + b + Ctrl+B Back one character - ctrl + f + Ctrl+F Forward one character - ctrl + l + Ctrl+L Clear screen - ctrl + n + Ctrl+N Next history item - ctrl + p + Ctrl+P Previous history item - ctrl + z + Ctrl+Z Moves running process into background. Type - fg and press enter + fg and press Enter to return. Doesn't work on Windows - ctrl + w or ctrl - + backspace + Ctrl+W or Ctrl + +Backspace Delete backward to a word boundary - ctrl + backspace Doesn't + Ctrl+Backspace Doesn't work on Linux, Mac and Windows - ctrl + delete + Ctrl+Delete Delete forward to a word boundary Doesn't work on Mac - ctrl + left or - meta + b + Ctrl+Left arrow or + Meta+B Word left - ctrl + left Doesn't work + Ctrl+Left arrow Doesn't work on Mac - ctrl + right or - meta + f + Ctrl+Right arrow or + Meta+F Word right - ctrl + right Doesn't work + Ctrl+Right arrow Doesn't work on Mac - meta + d or meta - + delete + Meta+D or Meta + +Delete Delete word right - meta + delete Doesn't work + Meta+Delete Doesn't work on windows - meta + backspace + Meta+Backspace Delete word left Doesn't work on Mac