perlfaq nodetype
faq_monk
<P>
The easiest way to do this is to read a key in nonblocking mode with the Term::ReadKey module from
<FONT SIZE=-1>CPAN,</FONT> passing it an argument of -1 to indicate not to block:
<P>
<PRE> use Term::ReadKey;
</PRE>
<P>
<PRE> ReadMode('cbreak');
</PRE>
<P>
<PRE> if (defined ($char = ReadKey(-1)) ) {
# input was waiting and it was $char
} else {
# no input was waiting
}
</PRE>
<P>
<PRE> ReadMode('normal'); # restore normal tty settings
</PRE>
<P>