From: Dave Burt Date: 2006-06-07T13:36:17+09:00 Subject: Re: pausing until a character is received Sy Ali wrote: > I'm struggling to figure out how to pause my script and await a single > character. I've been using gets which works to pause but I'd like to > do it more cleanly. > > My best lead has been in this ruby quiz[1], and the reference to > STDIN.getc .. however, having fumbled from a few angles, I'm still not > able to get it working the way I want. From the quiz summary: begin require "Win32API" def read_char Win32API.new("crtdll", "_getch", [], "L").Call end rescue LoadError def read_char system "stty raw -echo" STDIN.getc ensure system "stty -raw echo" end end > I'd like to pause until any character is received, and be able to > gracefully rescue from an Interrupt. To handle the interrupt signal, or SIGINT (but do nothing): trap(:INT) {} > The best I can do is pause on any character but ignore the interrupt. > So ^c would act like any other character.. which isn't what I want. I don't understand your last paragraph. Is the code I posted what you were after? Cheers, Dave