File: capture-keys.pl

package info (click to toggle)
libtickit-perl 0.73-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 660 kB
  • sloc: perl: 4,944; makefile: 5
file content (28 lines) | stat: -rw-r--r-- 413 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/perl

use v5.14;
use warnings;

use Tickit::Term;

my $term = Tickit::Term->open_stdio;

$term->await_started( 0.05 );

my @keys;
$term->bind_event( key => sub {
   my ( $term, $ev, $info ) = @_;
   push @keys, $info;
});

sub get_next_key
{
   while(1) {
      return shift @keys if @keys;
      $term->input_wait;
   }
}

while( my $key = get_next_key ) {
   print "Pressed key ", $key->str, "\n";
}