Close a window when the ESC key is pressed

Insert this code on your form to force the window/page to close when the ESC key is pressed.
HTML • JavaScript


<body onKeyPress=microsoftKeyPress()></body>

function microsoftKeyPress() {
	if (window.event.keyCode == 27 )
		window.close();
}

Posted by fbrefere001 on Friday February 6, 2004