On this page

C

tty.ReadStream

History
class tty.ReadStream extends net.Socket

Represents the readable side of a TTY. In normal circumstances process.stdin will be the only tty.ReadStream instance in a Node.js process and there should be no reason to create additional instances.

P

readStream.isRaw

History

A boolean that is true if the TTY is currently configured to operate as a raw device.

This flag is always false when a process starts, even if the terminal is operating in raw mode. Its value will change with subsequent calls to setRawMode.

P

readStream.isTTY

History

A boolean that is always true for tty.ReadStream instances.

readStream.setRawMode(mode): this
Attributes
If true or 'raw', configures the tty.ReadStream to operate as a raw device. If 'io', configures the tty.ReadStream to operate in binary-safe I/O mode. If false, configures the tty.ReadStream to operate in its default mode. The readStream.isRaw property will be set to whether the stream is in raw mode, and the readStream.rawMode property will be set to the resulting mode.
Returns:this
The read stream instance.

Allows configuration of tty.ReadStream so that it operates as a raw device.

When in raw mode, input is always available character-by-character, not including modifiers. Additionally, all special processing of input characters by the terminal is disabled, including echoing input characters. Ctrl+C will no longer cause a SIGINT when in this mode. This mode does not affect terminal output processing, such as newline translation on Unix terminals.

On Windows, setRawMode() requires write permission to the console input buffer. When opening "\\\\.\\CONIN$" with the fs.open() family of APIs (for passing into new tty.ReadStream()), be sure to use a read/write flag such as 'r+'.

When in binary-safe I/O mode, terminal output processing is also disabled. This corresponds to libuv's UV_TTY_MODE_IO mode and is not supported on Windows.

P

readStream.rawMode

History
Attributes

The current raw mode for the tty.ReadStream. This is false when the stream is in its default mode, 'raw' when raw input mode is enabled, and 'io' when binary-safe I/O mode is enabled.