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

Use event.key over event.keyCode/which #4631

Merged
merged 4 commits into from
Feb 24, 2018

Conversation

kevinji
Copy link
Collaborator

@kevinji kevinji commented Jan 11, 2018

There are a few keyCode instances that I did not change, as they were trickier to modify correctly.

@erikdesjardins erikdesjardins added this to the v5.11.x (v5.12.0) milestone Jan 11, 2018
@@ -84,7 +84,7 @@ const commandLine = _.once(() => {
});

input.addEventListener('keyup', (e: KeyboardEvent) => {
if (e.keyCode === 27) {
if (e.key === 'Escape') {
Copy link
Collaborator

@jewel-andraia jewel-andraia Jan 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these constants be put in CommentTools.NAMED_KEYS.Escape, ...Enter for easier validation?

@@ -1078,24 +1078,6 @@ function lod() {
});
} */

export const KEYS = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep this as NAMED_KEYS = { SPACE: ' ', ENTER: 'Enter', ESCAPE: 'Escape', ... } for stronger validation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, sounds good to me.

@kevinji kevinji force-pushed the event-key branch 4 times, most recently from 6b47585 to 915bf79 Compare January 14, 2018 16:27
@jewel-andraia
Copy link
Collaborator

Thanks! Neat little refactor.

@erikdesjardins
Copy link
Collaborator

This needs testing in Edge (which I can do at some point), since apparently it has "non-standard key identifiers"... https://caniuse.com/#feat=keyboardevent-key

@kevinji
Copy link
Collaborator Author

kevinji commented Jan 25, 2018

Good catch; seems like the issue is fixed but not yet released. We'll need to add a shim similar to this for Edge to work.

@benmcgarry
Copy link
Collaborator

Depending when we expect this 5.12 to land we may be able to just avoid the shim. The fix should be released April timeish.

@kevinji
Copy link
Collaborator Author

kevinji commented Feb 20, 2018

I added a polyfill for Edge, so this should be mergeable. I don't have Edge to test with though.

@erikdesjardins
Copy link
Collaborator

Tested in Edge 16

@erikdesjardins erikdesjardins merged commit f605bd9 into honestbleeps:master Feb 24, 2018
@kevinji kevinji deleted the event-key branch February 24, 2018 21:08
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

Successfully merging this pull request may close these issues.

4 participants