I'm in a situation where I would like to do a Tk::exit(0) if any key is pressed or if any mouse movement occurs. I glanced through Mastering Perl/Tk but this situation is not typical so is not really covered. Is there a way to bind to all keys? Is there a way to bind to mouse movement even if the cursor is not over the MainWindow (or any widgets)? Is there a way to key off of any user input event?

As you may guess, this is screensaver related. For thin client users we disconenct sessions when the screensaver is supposed to kick off. What I'd like to do is give users an easy and convenient way to keep the session active. Think of working on your PC and noticing a warning popping up on your Sun Ray out of the corner of your eye. It would be really nice if you could tap any key or do a quick tap to the mouse to keep it alive, right?

Note: I have something that works off of the ENTER key or if they click a button. I'm just looking for guidance for binding to any user input. And in case it matters I'm using a grid layout.


In reply to Perl/Tk: Is there a way to key off of any user input event? by Argel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.