From: Bill Kelly Date: 2004-09-10T05:54:17+09:00 Subject: Re: Listening for Keypress while Working From: "Bill Kelly" > From: "James Edward Gray II" > > On Sep 9, 2004, at 2:23 PM, James Edward Gray II wrote: > > > > > What's the best way to go about this, select() over STDIN in my > > > processing loop? > > > > Hmm, I don't appear to be able to select() over STDIN. Now I'm really > > in need of a good idea... > > On win32... I haven't tried it... they seem to have > provided _kbhit() in ... Apparently implemented > in terms of win32 PeekConsoleInput()... Wow it actually seems to work (!) >> require 'dl' => true >> kbhit = Win32API.new("msvcrt", "_kbhit", [], 'I') => # >> kbhit.call => 0 >> 10.times { puts kbhit.call; sleep 1 } 0 0 1 # I hit spacebar here.... 1 1 1 1 1 1 1 HTH, Regards, Bill