SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict trican's Avatar
    Join Date
    Sep 2003
    Location
    someplace
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery catching the escape key

    Hi all,

    I'm trying to "catch" the escape key being press with the following:

    Code:
     $(document).keyup(function(e) {
                if( e.keyCode==27 && popupStatus==1){
                    alert('Handler for .keypress() called.');
    	        disablePopup();
    		    }
    
            });
    However its not working - but I dont understand why - anyone have opinions?
    Free Image Editing Webapp, includes
    easy to use creative transformations to
    enrich your digital photographs @www.PureRGB.com

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    The popupStatus variable isn't within your scope to check it?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Addict trican's Avatar
    Join Date
    Sep 2003
    Location
    someplace
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    aha! (or should that be doh). That solved the problem.

    I think I need to learn about scope rules pertaining to Javascript - I had naively assumed that the variable was global.
    Free Image Editing Webapp, includes
    easy to use creative transformations to
    enrich your digital photographs @www.PureRGB.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •