Get key event ESC on document


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



Copy this code and paste it in your HTML
  1. document.onkeydown = function(e){
  2. if (e == null) { // ie
  3. keycode = event.keyCode;
  4. } else { // mozilla
  5. keycode = e.which;
  6. }
  7. if(keycode == 27){ // escape, close box, esc
  8. //what you nedd
  9. }
  10. };

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.