1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#!perl use warnings; use strict; use 5.10.0; use Win32::Console; my $in = Win32::Console->new( STD_INPUT_HANDLE ); $in->Mode( ENABLE_PROCESSED_INPUT ); while ( 1 ) { my @event = $in->Input; my $event_type = shift @event; next if ! defined $event_type; if ( $event_type == 1 ) { my ( $key_down, $repeat_count, $v_key_code, $v_scan_code, $char, $ctrl_key_state ) = @event; next if ! $key_down; if ( $char ) { say $char; } else { next; } } else { next; } }
say sprintf "c:%04x vk:%04x sc:%04x r:%1s",$char,$v_key_code,$v_scan_code,chr($char&0xFF);