views:

39

answers:

1

I'm writting a Ruby program for windows, and I need to read user input from keyboard (stdin).

However, it's needed that the user key-presses are not automatically displayed in the windows console, and behave like "silent key presses"

This problem in Ruby over linux, can be solved using the "stty" linux command:

%x{stty -icanon -echo} 

because it is the linux terminal who automatically outputs the user-keys into the terminal, so running the "stty" command tells the terminal to stop showing the user-key-presses.

But my program must run in windows, so I tried searching for a "stty" equivalent command for windows console, but still found nip...

?any suggestions, pointers ?

A: 

Look at Highline gem. To clarify, look at ask method and provide a block to silence it's output. It is well exemplified in their documentation

Luis Lavena