This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Usually key events are dispatched to the focused element of the focused document. But there are cases when there is no focused element. Currently Gecko dispatches key events in such case to documentElement, webkit to body if there is one. (Opera couldn't handle my testcase and I haven't yet tested IE) I'm probably going to change Gecko to follow Webkit in this case since that behavior follows how activeElement works.
This is in fact already specified: http://www.whatwg.org/specs/web-apps/current-work/#focus "There may be no element focused; when no element is focused, key events received by the document must be targeted at" "the first child of the html element that is either a body element or a frameset element. If there is no such element, [...] they must instead be fired at the Document object". EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document: http://dev.w3.org/html5/decision-policy/decision-policy.html Status: Accepted Change Description: no spec change Rationale: This seems to have been fixed already. Please don't hesitate to reopen if the current definition is now Web-compatible.
Looks like the event should be dispatched to documentElement if there is no body or frameset.
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document: http://dev.w3.org/html5/decision-policy/decision-policy.html Status: Accepted Change Description: see diff given below Rationale: Concurred with reporter's comments based on light testing.
Checked in as WHATWG revision r6753. Check-in comment: Compatibility fix for how events are fired when nothing is focused and there's no body element. Also, editorial tweaks around how drag and drop events are fired to the body element. http://html5.org/tools/web-apps-tracker?from=6752&to=6753