title: Detect a keypress when a div element is visible
body: <p>I am making a light box gallery widget, now i need to detect the keypress and call to a function but only when the <code>#lightbox</code> element is visible, and if it is not, it should ignore the key press, using jquery, i tried the following:</p>
  
  <pre><code>        $("#lightbox").keyup(function(e) {
  alert(e.keyCode);
    if (e.keyCode == 27) { alert("a") }   // esc
  });
  </code></pre>
  
  <p>any sugestion guys?</p>