Skip to content

Commit 1ba5a56

Browse files
arve0addaleax
authored andcommitted
doc: readline.emitKeypressEvents and raw mode
`readline.emitKeypressEvents` needs `stream` to be in raw mode. PR-URL: #6628 Fixes: #6626 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Roman Klauke <[email protected]>
1 parent 9c33e0e commit 1ba5a56

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

doc/api/readline.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,15 @@ input.
364364
Optionally, `interface` specifies a `readline.Interface` instance for which
365365
autocompletion is disabled when copy-pasted input is detected.
366366

367+
Note that the stream, if it is a TTY, needs to be in raw mode:
368+
```js
369+
readline.emitKeypressEvents(process.stdin);
370+
if (process.stdin.isTTY) {
371+
// might not be a TTY if spawned from another node process
372+
process.stdin.setRawMode(true);
373+
}
374+
```
375+
367376
## readline.moveCursor(stream, dx, dy)
368377

369378
Move cursor relative to it's current position in a given TTY stream.

0 commit comments

Comments
 (0)