#!/usr/bin/perl use Tk; my $mw = new Tk::MainWindow; my $btn = $mw->Button(-text => 'Hit Return')->pack(); # # Note that we *usually* bind to the main window, # not the button - it's a focus thing. # $mw->bind('', \&_on_rtn); MainLoop; exit(0); sub _on_rtn { $mw->messageBox(-message=>'Thanx for using the keyboard!'); }