Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which, KeyCode, and CharCode are all deprecated #52

Open
jmpresso opened this issue Nov 6, 2018 · 0 comments
Open

Which, KeyCode, and CharCode are all deprecated #52

jmpresso opened this issue Nov 6, 2018 · 0 comments

Comments

@jmpresso
Copy link

jmpresso commented Nov 6, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant