Skip to content

Commit 2273971

Browse files
arve0evanlucas
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 1c7b6e2 commit 2273971

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

doc/api/readline.md

+9
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,15 @@ Move cursor to the specified position in a given TTY stream.
362362
Causes `stream` to begin emitting `'keypress'` events corresponding to its
363363
input.
364364

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

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

0 commit comments

Comments
 (0)