Reputation: 1006
I have a javascript window.open popup, and I want to prevent popup from getting close by itself when the user presses the ESC key. I can't figure out how to hook the keydown event (and on what object?) so that I can catch the ESC key.
Please help me out!.
Upvotes: 2
Views: 5490
Reputation: 1
You should not do this. Escape is the standard key for closing popups, and you will likely create a keyboard trap for anyone who depends on the keyboard interface.
Upvotes: 0
Reputation: 3007
var myWindow = window.open();
myWindow.onkeydown = function(e){
if(e.keyCode === 27){
e.preventDefault();
}
};
Upvotes: 4