// Unpause stream for stdin process.stdin.resume(); process.stdin.setEncoding('utf8'); // Set raw mode (read by char) // http://unix.stackexchange.com/questions/21752/whats-the-difference-between-a-raw-and-a-cooked-device-driver process.stdin.setRawMode(true); // Subscribe to data retrieving event process.stdin.on('data', function (chunk) { // Check if end of data stream reached (http://en.wikipedia.org/wiki/List_of_Unicode_characters) if (chunk === '\u0003'){ console.log("Bye bye, User!"); } });