jQuery catching the escape key

Hi all,

I’m trying to “catch” the escape key being press with the following:

 $(document).keyup(function(e) {
            if( e.keyCode==27 && popupStatus==1){
                alert('Handler for .keypress() called.');


However its not working - but I dont understand why - anyone have opinions?

The popupStatus variable isn’t within your scope to check it?

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.