Kenneth McDonald wrote:
> In the following bit of code:
> 
> print STDIN.getc
> STDOUT.flush
> 
> The code for whatever key I type isn't actually printed out until I go
> on to hit the return key. How can I have it printed as soon as I type
> a character key?
> 
> Thanks,
> Ken

It's not in Ruby standard. Under Windows you can do it like this:

def read_char
  require "Win32API"
  Win32API.new("crtdll", "_getch", [], "L").Call
end

Found here: http://www.rubyquiz.com/quiz5.html

TPR.
-- 
Posted via http://www.ruby-forum.com/.