Masoud Nazari Masoud Nazari - 1 year ago 71
Javascript Question

How close popup window on ESC keydown on javascript

My problem is like this: ESC-problem

But the difference is that, I do not have access to content of child window( I cant put script in that).

Is that possible that I handle

keydown in parent window for child window.

Answer Source

This is all you need.

var myWindow =;

myWindow.onkeydown = function(e){
    if(e.keyCode === 27){
        alert('esc key pressed');