From: I G Date: 2007-03-16T16:09:42+09:00 Subject: Trapping ESC key ------=_Part_29959_24901533.1174028980443 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I am a Ruby newbie and am trying to implement problem 1 mentioned here - http://www.rubyrailways.com/implementing-15-exercises-for-learning-a-new-programming-language/ I am stuck and can't find a simple and portable way to trap the ESC key. Any pointers, help is most appreciated. The code I have now is - require 'Win32API' def getchar char = Win32API.new("crtdll", "_getch", [], 'L').call if char == 27 # ESC key exit end end i = 0 loop do print "#{i+=1}, " getchar end Thanks. ------=_Part_29959_24901533.1174028980443--