5 The `tty` module houses the `tty.ReadStream` and `tty.WriteStream` classes. In
6 most cases, you will not need to use this module directly.
8 When Node.js detects that it is being run inside a TTY context, then `process.stdin`
9 will be a `tty.ReadStream` instance and `process.stdout` will be
10 a `tty.WriteStream` instance. The preferred way to check if Node.js is being run
11 in a TTY context is to check `process.stdout.isTTY`:
14 $ node -p -e "Boolean(process.stdout.isTTY)"
16 $ node -p -e "Boolean(process.stdout.isTTY)" | cat
22 A `net.Socket` subclass that represents the readable portion of a tty. In normal
23 circumstances, `process.stdin` will be the only `tty.ReadStream` instance in any
24 Node.js program (only when `isatty(0)` is true).
28 A `Boolean` that is initialized to `false`. It represents the current "raw" state
29 of the `tty.ReadStream` instance.
31 ### rs.setRawMode(mode)
33 `mode` should be `true` or `false`. This sets the properties of the
34 `tty.ReadStream` to act either as a raw device or default. `isRaw` will be set
35 to the resulting mode.
39 A `net.Socket` subclass that represents the writable portion of a tty. In normal
40 circumstances, `process.stdout` will be the only `tty.WriteStream` instance
41 ever created (and only when `isatty(1)` is true).
47 Emitted by `refreshSize()` when either of the `columns` or `rows` properties
51 process.stdout.on('resize', () => {
52 console.log('screen size has changed!');
53 console.log(`${process.stdout.columns}x${process.stdout.rows}`);
59 A `Number` that gives the number of columns the TTY currently has. This property
60 gets updated on `'resize'` events.
64 A `Number` that gives the number of rows the TTY currently has. This property
65 gets updated on `'resize'` events.
69 Returns `true` or `false` depending on if the `fd` is associated with a
72 ## tty.setRawMode(mode)
74 Stability: 0 - Deprecated: Use [tty.ReadStream#setRawMode][] (i.e. process.stdin.setRawMode) instead.
76 [tty.ReadStream#setRawMode]: #tty_rs_setrawmode_mode