在dumpkeys --long-info
Linux 终端中调用后,我得到以下值:
# ...
0x0000 nul
0x0001 Control_a
0x0002 Control_b
0x0003 Control_c
0x0004 Control_d
# ...
当我运行此脚本并按Ctrl a
or时,Ctrl b
我会得到相应的值。
当我按下Ctrl Space
ReadKey
返回时0
。
这个 null 是否意味着它是的值,Ctrl Space
或者它是否意味着没有设置或为空的东西?
#!/usr/bin/env perl
use warnings;
use strict;
use Term::ReadKey;
ReadMode('cbreak');
print "Press keys to see their ASCII values. Use Ctrl-C to quit.\n";
while (1) {
my $char = ReadKey(0);
last unless defined $char;
printf("$char -> Hex: %x\n", ord($char), ord($char));
}
ReadMode('normal');
# -> Hex: 1 # Ctrl a
# -> Hex: 2 # Ctrl b
# -> Hex: 4 # Ctrl d
# -> Hex: 0 # Ctrl Space