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;
In reply to Re: detecting the keystroke.
by almut
in thread detecting the keystroke.
by ybnormal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |