in reply to Problem with ReadKey
#!/usr/bin/perl use Term::ReadKey; use Time::HiRes qw(time); ReadMode 3; # 'noecho'; while (1) { my $key; my $wait_until = time + 3; while ( time < $wait_until ) { $key = ReadKey( -1 ); if ( defined $key ) { print STDERR "keystroke $key\t"; } } print "Something\n"; }
Be prepared to type in perl -e 'use Term::ReadKey; ReadMode 1;' blindly after executing the script to gt a working terminal again ;-)
Maybe some security feature (SELinux or AppArmor) gets in the way on your machine
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Problem with ReadKey
by Fox (Pilgrim) on Nov 04, 2010 at 15:04 UTC |