Hi,

how can a sleeping program react to a key that was pressed without
return being pressed?


perl -e 'use Term::ReadKey; my $ke = ReadKey(10); print "k: $ke\n";'


... shows that:


+ ReadKey() returns undef after the timeout

+ ReadKey() returns undef after the timeout even when you pressed keys

+ ReadKEy() returns the first key of those that were pressed before the
    timeout expires when you hit return before it does


So you always have to hit return :(

I'm finding that entirely useless for instances in which a program is
sleeping for some time (let's say 10 minutes) but supposed to do
something immediately when a key is pressed, and without pressing
return.  For example, I might want to press 'q' to quit and don't want
to wait 10 minutes for the program to react, and of course, I don't want
to press enter.

How can that be done?


-- 
"Didn't work" is an error.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to