in reply to Term::ReadKey - How can I get PgUp, PgDn etc ?

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:

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);
You may of course have to adjust some of the values to work on your system.

/J\

Replies are listed 'Best First'.
Re^2: Term::ReadKey - How can I get PgUp, PgDn etc ?
by Anonymous Monk on Aug 18, 2005 at 07:12 UTC
    That doesn't apply to windows.