node/doc/api/tty.markdown

31 lines
621 B
Markdown
Raw Normal View History

2012-02-28 03:09:35 +08:00
# TTY
Stability: 3 - Stable
Use `require('tty')` to access this module.
2011-02-21 05:53:40 +08:00
Example:
var tty = require('tty');
process.stdin.resume();
tty.setRawMode(true);
2011-02-21 05:53:40 +08:00
process.stdin.on('keypress', function(char, key) {
if (key && key.ctrl && key.name == 'c') {
console.log('graceful exit');
process.exit()
}
});
2012-02-28 03:09:35 +08:00
## tty.isatty(fd)
Returns `true` or `false` depending on if the `fd` is associated with a
terminal.
2012-02-28 03:09:35 +08:00
## tty.setRawMode(mode)
2011-02-25 08:36:43 +08:00
`mode` should be `true` or `false`. This sets the properties of the current
process's stdin fd to act either as a raw device or default.