#!/usr/bin/perl use warnings; use strict; use Tk; my $mw=tkinit; my @selects; my $lb1 = $mw->Listbox->pack(); $lb1->insert('end',('A'..'J')); $lb1->bind('' => sub{ $lb1->focus }); $mw->bind('' => sub { $lb1->focus; my $e = $lb1->XEvent; # get reference to X11 event structure my $key = $e->K; # comment out the if {} and see what happens if( $key eq 'Return' ){ push @selects, $lb1->get('active'); $lb1->itemconfigure('active', -background => 'yellow'); } $mw->update; print "@selects\n"; } ); MainLoop;