in reply to detecting the keystroke.
I read some thread saying ReadKey can do it, but not sure how I can do it in this scenario.
You could use non-blocking reads:
#!/usr/bin/perl use Term::ReadKey; ReadMode 3; # echo off my $msg = "Somebody, stop me.."; while(1){ print "$msg\n"; sleep(1); my $key = ReadKey(-1); # -1 means non-blocking if (defined($key) and $key eq "s") { $msg = "somebody, start me"; } } ReadMode 0;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: detecting the keystroke.
by ybnormal (Novice) on Apr 28, 2010 at 06:59 UTC |