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

Synthetic KeyboardEvent should support KeyboardEvent.code #14102

Closed
jjspace opened this issue Nov 5, 2018 · 8 comments · Fixed by #18287
Closed

Synthetic KeyboardEvent should support KeyboardEvent.code #14102

jjspace opened this issue Nov 5, 2018 · 8 comments · Fixed by #18287

Comments

@jjspace
Copy link

jjspace commented Nov 5, 2018

Do you want to request a feature or report a bug?
Feature

What is the current behavior?
The current synthetic keyboard event does not support the KeyboardEvent.code property.

What is the expected behavior?
The synthetic keyboard event should pass along the KeyboardEvent.code property. This is currently in the WD of DOM Events but is part of replacing keyCode and charCode and is much more consistent and easy to use. This is currently only supported by FF and Chrome (CanIUse) so it may be a bit premature to fully integrate. However keyCode, charCode and which are being deprecated so this will eventually need to be added.

Edit: I spoke too quickly, CanIUse shows that FF, Chrome, Safari and Opera support it. IE, Edge and most mobile browsers do not.

@philipp-spiess
Copy link
Contributor

Seems like Safari also supports this (looking at caniuse.com). Do you want to send a PR? 🙂

@charliesmart
Copy link

charliesmart commented Nov 7, 2018

It seems like the KeyboardEvent.key property should also probably added. I'd be happy to send a PR for both if you don't hear back from @jjspace

@philipp-spiess
Copy link
Contributor

@jjspace
Copy link
Author

jjspace commented Nov 7, 2018

@philipp-spiess is right, key is already there and implemented correctly (this was what I adapted my code to use in lieu of code) I'm happy to take a look at adding code but I wont have much time until the weekend if @charliesmart or someone else wants to do it before then. It doesn't seem like a large change apart from browser support.

@jjspace
Copy link
Author

jjspace commented Nov 11, 2018

I've created the PR to pass the code property along to the synthetic event. I looked into solutions to provide a polyfill to browsers without support like Edge and IE but the property is actually very complicated and needs access to the actual hardware keycodes as seen here so it's not really possible.

This should also have a change in the docs. How do I go about updating those? Also, when I do would it make sense to comment on the partial lack of browser support?

@mydiemho
Copy link

is there any updates on this?

@kgabryje
Copy link

kgabryje commented Aug 7, 2019

Is anyone working on this? Or can I take it?

@pushpinder107
Copy link

You can access the native event using event.nativeEvent so event code is available at event.nativeEvent.code

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

Successfully merging a pull request may close this issue.

6 participants