DEV Community

Discussion on: Pure Javascript Multiple Modals on a Page - Simplest

Collapse
 
manishfoodtechs profile image
manish srivastava

var KEYCODE_ESC = 27;

$(document).keyup(function(e) {
if (e.keyCode == KEYCODE_ESC) $('.cancel').click();
});

Collapse
 
jackttcoms profile image
jackdev

ooo thanks. is it possible in vanilla javascript? thanks so much.

Thread Thread
 
realto619 profile image
Paul Leech

I converted it to vanilla JS here: codepen.io/Realto619/pen/ZEyWjKm