The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/local/bin/perl -w
use Tk;
use Tk::Menubar;

my $mw = MainWindow->new;
my $mb = $mw->Menubar;
$mb->Menubutton(-text => '~File', -font => 'fixed', -menuitems =>
                [
                 [Button => '~Quit', -font => 'fixed', -command => [$mw,'destroy']]
                ]);
my $f  = $mw->Frame(-width => 100, -height => 100, -borderwidth => 2,
                    -takefocus => 1, -highlightborderwidth=> 3,
                    -highlightforeground => 'black')->pack;

my $qual;
foreach $qual ('',qw(Meta- Shift- Control- Alt-))
 {
  $f->bind("<${qual}KeyPress>",[ \&showit, "${qual}KeyPress" ]);
 }

$mw->update;
$f->focus;

MainLoop;

sub showit
{
 my ($w,$kind) = @_;
 my $ev = $w->XEvent;
 print "$kind ",$ev->K," ",$ev->A,"\n";
}