How do I hide an element when the escape key is pressed?

jquery

Solution

Since "close()" is not defined and there was a bracket missing...

$(document).keyup(function(e) {
    if (e.which == 27) {
        $(".overlayInner").fadeOut(300); 
    }
});

Problem

I found the following script for creating an overlay that opens in it another page: ``` <script> $("a#selector").live("click", function(){ $(".overlayInner").load("logwork_form.php", // the following is the callback function(){$(".overlayOuter").fadeIn(300); }); }); </script> ``` I'd like to ask you to help me with adding some extra functionality to the script: closing the overlay on pressing the esc key. I've tried adding the below code but it doesn't work. ``` //close if esc key is pres $(document).keyup(function(e) { if (e.keyCode == 27) { $(".overlayInner").close("logwork_form.php?proiect_id=13", function({ $(".overlayOuter").fadeOut(300); }); ```

Original source