On my website I provide an editor window (simple HTML div with textarea). It can be closed by Escape key.
Javascript:
$(document).keyup( function(e)
{
// ESCAPE KEY closes editor window
if(e.which == 27)
{
// trigger cancel button to hide the editor window
$('#cancelbtn').click();
return;
}
});
The problem:
The user might use the browser search bar:
When the user hits the ESC key to close the search, it also triggers the javascript code. Consequently the editor window is closed.
How to detect if the search bar of the browser is open? And then not trigger the ESC key cancel.
