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

Please don't overwrite event.key if it already exists #20

Open
nikparo opened this issue Apr 10, 2018 · 2 comments
Open

Please don't overwrite event.key if it already exists #20

nikparo opened this issue Apr 10, 2018 · 2 comments

Comments

@nikparo
Copy link

nikparo commented Apr 10, 2018

This polyfill currently overwrites the native KeyboardEvent.prototype.key on Internet Explorer and Edge. I understand that this is to ensure that IE and Edge give the standard value for some keys, but this polyfill is still in many ways inferior to the native implementation. It is missing many keys, it has no locale support #11, and the returned key for keypresses are wrong #15.

I have recently written a shim that fixes most bad key values of non-standard, native event.key implementations: https://github.com/nikparo/keyboardevent-key-standardiser-shim/ . My shim would play well with this one, unfortunately this one doesn't play well with mine :/

Would you please remove the isEdgeOrIE check? Thanks.

@danielbsig
Copy link

Is the isEdgeOrIE check the only thing that needs changing? I noticed you forked the repo but didn't modify this check. Did that change cause some other side effects?

@nikparo
Copy link
Author

nikparo commented Nov 9, 2018

I think that fork was only created for a pull request (#19). I don't actually use this or that in any code at the moment, for no good reason other than that I already had a polyfill in place in my main project that covers what I need.

I see no reason removing the check would cause side-effects, as long as you pair it with my shim to standardise the keys. (We use it in producation and have recieved no bug reports) The code would be something like:

function polyfill () {
  if (!('KeyboardEvent' in window) || ('key' in KeyboardEvent.prototype)) {
    return false;
  }
  ...

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

2 participants