AnyEvent-TermKey

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

     my $cv = AnyEvent->condvar;
 
     my $aetk = AnyEvent::TermKey->new(
        term => \*STDIN,
 
        on_key => sub {
           my ( $key ) = @_;
 
           print "Got key: ".$key->termkey->format_key( $key, FORMAT_VIM )."\n";
 
           $cv->send if $key->type_is_unicode and
                        $key->utf8 eq "C" and
                        $key->modifiers & KEYMOD_CTRL;
        },
     );
 
     $cv->recv;

DESCRIPTION
    This class implements an asynchronous perl wrapper around the
    "libtermkey" library, which provides an abstract way to read keypress

examples/demo.pl  view on Meta::CPAN

my $cv = AnyEvent->condvar;

my $aetk = AnyEvent::TermKey->new(
   term => \*STDIN,

   on_key => sub {
      my ( $key ) = @_;

      print "Got key: ".$key->termkey->format_key( $key, FORMAT_VIM )."\n";

      $cv->send if $key->type_is_unicode and
                   $key->utf8 eq "C" and
                   $key->modifiers & KEYMOD_CTRL;
   },
);

$cv->recv;

lib/AnyEvent/TermKey.pm  view on Meta::CPAN

 my $cv = AnyEvent->condvar;
 
 my $aetk = AnyEvent::TermKey->new(
    term => \*STDIN,
 
    on_key => sub {
       my ( $key ) = @_;
 
       print "Got key: ".$key->termkey->format_key( $key, FORMAT_VIM )."\n";
 
       $cv->send if $key->type_is_unicode and
                    $key->utf8 eq "C" and
                    $key->modifiers & KEYMOD_CTRL;
    },
 );
 
 $cv->recv;

=head1 DESCRIPTION

This class implements an asynchronous perl wrapper around the C<libtermkey>

t/01passthrough.t  view on Meta::CPAN

my $sym = $aetk->keyname2sym( 'Space' );

ok( defined $sym, "defined keyname2sym('Space')" );

is( $aetk->get_keyname( $sym ), 'Space', "get_keyname eq Space" );

my $key;

ok( defined( $key = $aetk->parse_key( "A", 0 ) ), '->parse_key "A" defined' );

ok( $key->type_is_unicode,     '$key->type_is_unicode' );
is( $key->codepoint, ord("A"), '$key->codepoint' );
is( $key->modifiers, 0,        '$key->modifiers' );

is( $aetk->format_key( $key, 0 ), "A", '->format_key yields "A"' );

t/02on_key.t  view on Meta::CPAN

   on_key => sub { ( $key ) = @_; $cv->send; },
);

$wr->syswrite( "h" );

undef $key;
$cv->recv;

is( $key->termkey, $aetk->termkey, '$key->termkey after h' );

ok( $key->type_is_unicode,     '$key->type_is_unicode after h' );
is( $key->codepoint, ord("h"), '$key->codepoint after h' );
is( $key->modifiers, 0,        '$key->modifiers after h' );

is( $key->utf8, "h", '$key->utf8 after h' );

is( $key->format( 0 ), "h", '$key->format after h' );

undef $aetk;



( run in 0.414 second using v1.01-cache-2.11-cpan-88abd93f124 )