From: Sean O'Halpin Date: 2005-09-26T19:47:31+09:00 Subject: Re: IO#getc behavior Hi Jon, this is what I use: --- CODE --- ## # getch and kbhit for win32 # Sean O'Halpin # require 'dl/import' module Win32API extend DL::Importer dlload 'crtdll.dll' ## # kbhit - returns 0 if nothing waiting, non-zero otherwise # extern 'int _kbhit()', :stdcall ## # getch - blocks waiting for one character of input from console # Note: returns integer representing character # Use getch.chr to get one character string # extern 'int _getch()', :stdcall alias :kbhit :_kbhit alias :getch :_getch module_function :kbhit, :getch end if __FILE__ == $0 puts "kbhit" puts "Hit any key" while true x = Win32API.kbhit if x > 0 puts Win32API.getch.chr break else print "." end end end --- END CODE --- HTH, Sean