Module to detect keyboard presses
am 30.03.2007 14:09:19 von Ignoramus3938I have a script that runs in a loop and I would like it to accept
OPTIONAL keypresses.
e.g.
while( 1 ) {
do_my_stuff();
my $key = get_optional_key();
if( defined $key ) { # key was pressed
if( $key eq 'b' ) { skip_backwards(); }
elsif( $key eq 'f' ) { skip_forward(); }
elsif( $key eq ' ' ) { pause(); }
} else {
print "No key was pressed.\n";
}
}
The key point here is that I do NOT want to wait for mandatory keys at
every iteration, I just want a nonblocking call to get a [possible]
key press event[s];
MS-DOS used to have this facility a long time ago.
I would like to know if there is already a module for this.
I am using Linux.
thanks
i