Bug 156446 - keyCode and charCode properties should live in KeyboardEvent, not UIEvent
Summary: keyCode and charCode properties should live in KeyboardEvent, not UIEvent
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Mac OS X 10.11
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-09 15:12 PDT by Chris Rebert
Modified: 2020-08-22 05:45 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Rebert 2016-04-09 15:12:27 PDT
The following evaluates to true in WebKit Nightly, and to false in Chrome, Firefox, and Edge:

'keyCode' in UIEvent.prototype && 'charCode' in UIEvent.prototype


Per the UI Events spec, keyCode and charCode should be properties of KeyboardEvent, not of UIEvent. See:
* https://w3c.github.io/uievents/#interface-uievent
* https://w3c.github.io/uievents/#legacy-interface-KeyboardEvent
Comment 1 Simon Fraser (smfr) 2016-04-09 16:04:22 PDT
keyCode and charCode were present on UIEvent from long ago in the codebase. KeyboardEvent has them in the IDL, but hidden from JavaScript, oddly.

Neither match the spec[1], which has:
  readonly attribute DOMString key;
  readonly attribute DOMString code;

[1] https://w3c.github.io/uievents/#events-keyboardevents
Comment 2 Chris Rebert 2016-04-09 16:31:21 PDT
To clarify, I'm referring to the legacy[1] KeyboardEvent.keyCode and KeyboardEvent.charCode properties:
  partial interface KeyboardEvent {
    // The following support legacy user agents
    readonly attribute unsigned long charCode;
    readonly attribute unsigned long keyCode;

which are distinct from the modern[2] KeyboardEvent.key and KeyboardEvent.code properties.

[1]: https://w3c.github.io/uievents/#legacy-interface-KeyboardEvent
[2]: https://w3c.github.io/uievents/#events-keyboardevents
Comment 3 Lucas Forschler 2019-02-06 09:18:36 PST
Mass move bugs into the DOM component.
Comment 4 Rob Buis 2020-08-22 05:45:18 PDT
This was fixed by r209895.