Module to detect keyboard presses

I 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
Ignoramus3938 [ Fr, 30 März 2007 14:09 ] [ ID #1674571 ]
Perl » comp.lang.perl.modules » Module to detect keyboard presses

Vorheriges Thema: UTF8 on DBI with Perl
Nächstes Thema: HTTP::Response decoded_content is undefined