From: RubyCrazy Date: 2007-03-16T20:12:26+09:00 Subject: Re: Trapping ESC key ------=_Part_31146_7847078.1174043543541 Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 3/16/07, Harry wrote: > > > > > I am stuck and can't find a simple and portable way to trap the ESC key= . > Any > > pointers, help is most appreciated. > > > > > Will this do it? > > > http://blog.grayproductions.net/articles/2006/10/01/i-just-want-one-chara= cter > > Harry > Harry, I have tried HighLine but that's not what I want (or am I making a mistake here?). I am trying to solve the problem - ** "Display series of numbers (1,2,3,4, 5=85.etc) in an infinite loop. The program should quit if someone hits a specific key (Say ESCAPE key)." Somehow I want to keep checking in a thread (this should be non-blocking) for the ESC key press. Once ESC is pressed my program terminates. Right now= , my thread code blocks till I press ESC key, as you can see here - require 'Win32API' def getchar char =3D Win32API.new("crtdll", "_getch", [], 'L').call if char =3D=3D 27 # ESC key exit end end i =3D 0 loop do print "#{i+=3D1}, " getchar end What should I do? Thanks. ------=_Part_31146_7847078.1174043543541--