in reply to Re^2: Grabbing input - every char, not after <Enter>
in thread Grabbing input - every char, not after <Enter>
run that:use Term::ReadKey; ReadMode 4; # Turn off controls keys while (not defined ($key = ReadKey(-1))) { # No key yet select undef,undef,undef,0.1; # sleep 0.1 secon +d } print "Get key $key\n"; ReadMode 0; # Reset tty mode before exiting
update: the while() look does take up a tremendous amount of CPU time, though, so I added the select() call$ perl test.pl <press d> Get key d $
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Grabbing input - every char, not after <Enter>
by true_atlantis (Acolyte) on Sep 17, 2007 at 22:31 UTC |