Given a particular terminal type ReadKey() may need to be called repeatedly to retrieve a multicharacter code for a given control key - so for instance on an xterm on this computer I could use something like:
You may of course have to adjust some of the values to work on your system.use Term::ReadKey; my $key = ''; ReadMode(4); + my %keys = ( A => 'KeyUp', B => 'KeyDown', C => 'KeyRight', D => 'KeyL +eft'); while ($key ne 'q' ) { while (not defined ($key = ReadKey(-1))) { # No key yet } + if ( ord($key) == 27 ) { if( ReadKey(-1) eq '[' ) { $key = ReadKey(-1); + print $keys{$key},"\n"; } } } print "\n"; ReadMode(0);
/J\
In reply to Re: Term::ReadKey - How can I get PgUp, PgDn etc ?
by gellyfish
in thread Term::ReadKey - How can I get PgUp, PgDn etc ?
by Sioln
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |