#!/usr/bin/perl use Term::ReadKey; use strict; use warnings; use constant KDSKBMODE => 0x4B45; use constant K_XLATE => 0x01; use constant K_MEDIUMRAW => 0x02; $SIG{ALRM} = sub { ioctl(STDIN, KDSKBMODE, K_XLATE); # Return to XLATE ReadMode 0; exit; }; ReadMode 4; ioctl(STDIN, KDSKBMODE, K_MEDIUMRAW); # Set keyboard to MEDIUMRAW while(1) { my $char = getc(STDIN); print "keycode ", (ord($char) & 0x7f), (ord($char) & 0x80) ? " + release" : " press", "\n"; alarm(10); }
In reply to Simple "showkey" in Perl by Mr_Person
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |