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

[core] Remove keycode() #14248

Merged
merged 1 commit into from
Jan 20, 2019
Merged

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Jan 19, 2019

All of keyCode, which, charCode and keyIdentifier are deprecated. The key property is the new standard.
As of the time of this writing, the key property is supported by all major browsers as of : Firefox 52, Chrome 55, Safari 10.1, Opera 46. Except Internet Explorer 11 which has : non-standard key identifiers.
React synthetic event normalize all of that: https://github.com/facebook/react/blob/10a7a5b5ced683125d68584a78084faac3197846/packages/react-dom/src/events/getEventKey.js#L79 so we can apply this simple change:

-import keycode from 'keycode';

-const key = keycode(event);
+const key = event.key;

🚀 Removing the keycode dependency saves us 860 B gzipped.

capture d ecran 2019-01-26 a 14 55 17

@oliviertassinari oliviertassinari force-pushed the remove-keycode branch 8 times, most recently from 98a34e5 to b617bce Compare January 19, 2019 13:33
@oliviertassinari oliviertassinari changed the title [core] Remove keycode [core] Remove keycode() Jan 19, 2019
@oliviertassinari oliviertassinari force-pushed the remove-keycode branch 2 times, most recently from c53fc54 to 289d0ad Compare January 19, 2019 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant