Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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!
@csanz

This comment has been minimized.

Copy link

commented Apr 23, 2011

awesome + clean + useful piece of code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.