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

feat: use KeyboardEvent.key instead of KeyboardEvent.keyCode #803

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

AntoineMoues
Copy link
Contributor

Description

This MR goal is to get rid of the usage of KeyboardEvent.keyCode which is a deprecated standard as you can see on MDN documentation. As of today, this is still supported by all browsers but might no be the case in the future.

Two API have the potential to replace keyCode and they're KeyboardEvent.code and KeyboardEvent.key.

KeyboardEvent.code returns a representation of the key pressed while KeyboardEvent.key returns the value as it will be printed. In our case, we want to exclude specific printed values so key usage makes more sense.

Also, KeyboardEvent.key is more supported by browsers (partial support up to IE 8 for instance).

This PR closes #612 issue.

Reproduction instructions

Tests should pass.

@AntoineMoues AntoineMoues added the enhancement New feature or request label Apr 25, 2024
@AntoineMoues AntoineMoues requested a review from vscav April 25, 2024 12:39
@AntoineMoues AntoineMoues self-assigned this Apr 25, 2024
Copy link
Member

@vscav vscav left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @AntoineMoues 💪

@AntoineMoues AntoineMoues merged commit ed16c4a into master Apr 29, 2024
17 checks passed
@AntoineMoues AntoineMoues deleted the use-keyboard-event-key branch April 29, 2024 07:39
legallai pushed a commit to legallai/ember-amount-input that referenced this pull request Jul 2, 2024
feat: use KeyboardEvent.key instead of KeyboardEvent.keyCode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KeyboardEvent.keyCode compatibility issue
2 participants