How to Hide/Close Popup by “Esc” key from keyboard ?

hide popup by press ESC key

Sometime we want to hide the popup or run any script by just pressing “Esc” key from the keyborad..

Here is simple code..

// hide popup model by pressing escape button
$( document ).on( 'keydown', function ( e ) {
if ( e.keyCode === 27 ) { // ESC
$('.popupimg').remove();
$("#nst-popup").hide();
}
});
});

 
You can change the script as per your need… 🙂

 

If this help you then.. Can you buy a Cup of Coffee for me by nst webcreation paypal--OR-- nst webcreation blog coffee cup

Published by

NST

Myself Narender Singh Thakur ( NST ) and i share my Experience/Knowledge and Tricks for folks and beginners to solve their issues while making websites through this Planet.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Click to Chat