window.addEventListener('keypress', function(e){ if (e.keyCode == (window.event ? 27 : e.DOM_VK_ESCAPE)) { Overlay.hide(); } });The code is simple, We just want when user presses the “Escape” key on the keyboard to hide the overlay that was displayed on the screen. This worked in latest FF, but not in Chrome. And looks like it does not work for all the keys on the first line of my keyboard (I use Mac keyboard, not sure whether this is the cause of the issue or not). In order to capture the this event, I need to use “keydown” instead:
window.addEventListener('keydown', function(e){ if (e.keyCode == (window.event ? 27 : e.DOM_VK_ESCAPE)) { Overlay.hide(); } });Problem solved, but not an obvious one. Hope this helps.