UNCONFIRMED 35849
F5 and Ctrl-F cannot be suppressed with preventDefault
https://bugs.webkit.org/show_bug.cgi?id=35849
Summary F5 and Ctrl-F cannot be suppressed with preventDefault
Ivan Peters
Reported 2010-03-07 18:30:42 PST
event.preventDefault() appears to have no effect on F5 (refresh) and crtl-f (find) keys. For example, the following code will suppress all keyboard events except F5 and ctrl-f: ====== function cancelEvent(e) { e.preventDefault(); } document.addEventListener("keydown", cancelEvent); document.addEventListener("keypress", cancelEvent); document.addEventListener("keyup", cancelEvent); ====== This is a Windows-only issue. Obviously, the OS X version doesn't have F5 for refresh, but the above code will suppress command-R and command-F (and everything else I tried).
Attachments
Alexey Proskuryakov
Comment 1 2010-03-08 12:41:45 PST
Does this match IE behavior? I think this was done on purpose (and there are some more combinations that cannot be suppressed).
Ivan Peters
Comment 2 2010-03-08 13:24:46 PST
Hmmm. You are right, IE does do the same (and it does seem like something that might be deliberate). In IE, I can still suppress the key by setting event.keyCode to 0. Personally, I tend to agree with the idea that one shouldn't mess with established UI behaviours. But there are always exceptions to every rule and I'm facing one now so I'm tending to see it as a bug, or at least a bad idea. In a world where the browser is just used for viewing web pages it is worth trying to enforce some UI consistency. As browsers start to be used for more "applications" in windows with the default menus and toolbars hidden, making no allowances for exceptions can be a problem.
Note You need to log in before you can comment on or make changes to this bug.