Lightbox escape key


/ Published in: jQuery
Save to your folder(s)

Lightbox escape key


Copy this code and paste it in your HTML
  1. // lightbox fadeout on escape
  2. $(document).bind('keydown', function(e) {//use keydown instead of keypress because keypress doesn't work in Chrome and Opera
  3. if(e.keyCode==27){
  4. $("#lightbox").fadeOut(300);
  5. }
  6. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.