2012-02-28 03:09:35 +08:00
|
|
|
# TTY
|
2010-11-26 11:09:28 +08:00
|
|
|
|
2012-03-03 07:14:03 +08:00
|
|
|
Stability: 3 - Stable
|
|
|
|
|
2010-11-26 11:09:28 +08:00
|
|
|
Use `require('tty')` to access this module.
|
|
|
|
|
2011-02-21 05:53:40 +08:00
|
|
|
Example:
|
|
|
|
|
|
|
|
var tty = require('tty');
|
|
|
|
process.stdin.resume();
|
2011-10-29 02:07:06 +08:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2010-11-26 11:09:28 +08:00
|
|
|
|
2012-02-28 03:09:35 +08:00
|
|
|
## tty.isatty(fd)
|
2010-11-26 11:09:28 +08:00
|
|
|
|
|
|
|
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)
|
2010-11-26 11:09:28 +08:00
|
|
|
|
2011-02-25 08:36:43 +08:00
|
|
|
`mode` should be `true` or `false`. This sets the properties of the current
|
2010-11-26 11:09:28 +08:00
|
|
|
process's stdin fd to act either as a raw device or default.
|