When I press the Up-key, this script (Term::TermKey) outputs You pressed: <Up> .
#!/usr/bin/env perl
use warnings;
use 5.012;
use Term::TermKey;
my $tk = Term::TermKey->new( \*STDIN );
say "Press any key";
$tk->waitkey( my $key );
say "You pressed: <" . $tk->format_key( $key, 0 ) . ">";
How could I reach the same result with Win32::Console?
I tried this, but it worked only on “normal” keys like l,k, … but not with keys like Up, Delete, …
use Win32::Console;
my $in = Win32::Console->new(STD_INPUT_HANDLE);
$in->Mode(ENABLE_PROCESSED_INPUT);
my $result = $in->InputChar(1);
say "<$result>";
How could I make work keys like Up, Delete, … too with Win32::Console?
The up key does not result in a character.
InputCharcannot possible return it. You need to useInput.See KEY_EVENT_RECORD for more information about keyboard events.
See Virtual-Key Codes to identify keys.
Headers and definitions for above code: