A
arun
I want to interrupt something, when the user presses a key, or clicks
the mouse. The only solution for the keyboard I could come with, seems
overkill:
a=0
th=Thread.new {loop{a=STDIN.getc}}
loop do
a=0
sleep (1)
if a==0
puts "nothing pressed"
else
puts "key pressed"
end
end
Also, it requires that I press the Enter key... I would be very
grateful, if you could show me a better way.
Arun
the mouse. The only solution for the keyboard I could come with, seems
overkill:
a=0
th=Thread.new {loop{a=STDIN.getc}}
loop do
a=0
sleep (1)
if a==0
puts "nothing pressed"
else
puts "key pressed"
end
end
Also, it requires that I press the Enter key... I would be very
grateful, if you could show me a better way.
Arun