Escape key should be handled on keydown, not keyup

asked 2014-02-23 07:00:15 -0600

Neil gravatar image

I accidentally pressed the Escape key while composing a comment. An alert appeared asking

Are you sure you don't want to post this comment?

I made the mistake of trying to cancel the alert by pressing the Escape key. The alert was cancelled on the keydown of the Escape key... and then the subsequent keyup triggered the confirm abandon message again.

Obviously once I realised what was going on I used a different way of cancelling the alert, but the bug remains.

On a side note I noticed that just before you add the keyup escape handler you also add various event handlers to update the counter, normally I would suggest that the input event is the most reliable way to achieve this.

edit retag flag offensive close merge delete