in reply to Perl/TK KeyPress/Release minimized
Try this(Escape key is the only way to close):
#!/usr/bin/perl use Tk; $mw = MainWindow->new; # the window must be mapped for a global grab # so make a 1 pixel window in lower right corner $mw->geometry('1x1-1-1'); $mw->bind("<Key>", [ \&process_key_press , Ev('K') ] ); $mw->bind("<KeyRelease>", [ \&process_key_release , Ev('K') ] ); $mw->after(100,sub{$mw->grabGlobal;}); $mw->focusForce; MainLoop; sub process_key_press{ my ($caller, $key) = @_; print "Press $key\n"; if ($key eq 'Escape'){exit} } sub process_key_release{ my ($caller, $key) = @_; print "Release $key\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl/TK KeyPress/Release minimized
by ldln (Pilgrim) on Mar 23, 2008 at 00:00 UTC | |
by Anonymous Monk on Mar 24, 2008 at 14:46 UTC | |
by zentara (Cardinal) on Mar 24, 2008 at 15:51 UTC | |
by Anonymous Monk on Mar 24, 2008 at 19:09 UTC | |
by zentara (Cardinal) on Mar 25, 2008 at 13:58 UTC | |
|