当我按Up
- 键时,此脚本 ( Term::TermKey ) 输出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 ) . ">";
如何使用Win32::Console达到相同的结果?
我试过这个,但它只适用于“普通”键,如l
, k
, ... 但不适用于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>";
我怎么能用Up
, Delete
, ...制作工作键Win32::Console
?