From: Sard Aukary Date: 2006-09-08T20:42:27+09:00 Subject: Non blocking keypress reading? On Windows XP is there a way to test that a certain key has been pressed without blocking? I’ve tried using curses but it blocks the current thread and any other thread until a key is pressed. I want to give the user 10 seconds so make a selection before a default action is taken. Here is the test code I’ve got; require 'curses' include Curses init_screen noecho trap(0) { echo } t1 = Time.new Thread.new do #example timer thread while(true) do x = Time.new - t1 h = 3+3 setpos(12,10) addstr("#{x}") end end setpos(1,5) addstr("Please select your location") setpos(3,5) addstr(" 1 - Work") setpos(4,5) addstr(" 2 - Home") setpos(6,5) addstr("Esc - Exit") while (c = getch) != ?\e do # check what key is pressed and do stuff end -- Posted via http://www.ruby-forum.com/.