I have a dialogue box which appears, and I would like it to be hidden again when you hit the escape key.
That all works fine in IE, Firefox, Opera - the code registers a document.onkeypress
event handler when the box is shown, then tests the event keyCode to see if it's the escape key or not (keyCode 27), but this doesn't seen to work in WebKit based browsers (Chrome and Safari (3) ), though other keys can be captured this way.
Do WebKit browsers not to trigger an event at all when escape is pressed?
Does anyone know why this doesn't work, how to fix it, or know of a work-around.
Catch keydown/keyup instead. Take a look at this entry for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With