Skip to content

Which, KeyCode, and CharCode are all deprecated #52

Open
@jmpresso

Description

@jmpresso

Problem:

The event properties which, keyCode, and charCode are all removed from the Web standards. See the deprecation notice on MDN below:

https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/which
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/charCode

While they are supported now still in the major browsers, they may not be at some point in the future.

The preferred direction is to use event.key. The one problem is that IE and older versions of Edge use older versions of the "key" spec, and may return different values. The "Example" listed here shows some of the different values:

https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key

This shim is an example of how to re-mediate some of the differences: https://github.com/shvaikalesh/shim-keyboard-event-key/blob/master/index.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions