Created
August 7, 2010 18:40
-
-
Save isaacs/513059 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var stdin = process.stdin | |
, stdio = process.binding("stdio") | |
stdio.setRawMode() | |
// let the data flow. | |
// stdin is "paused" initially. | |
stdin.resume() | |
var password = "" | |
stdin.on("data", function (c) { | |
c = c + "" | |
switch (c) { | |
case "\n": case "\r": case "\u0004": | |
stdio.setRawMode(false) | |
console.log("you entered: "+password) | |
stdin.pause() | |
break | |
case "\u0003": | |
process.exit() | |
break | |
default: | |
password += c | |
break | |
} | |
}) | |
// hello, http://geekli.st! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
awesome + clean + useful piece of code.