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

Fix #6051 Deprecate keycode to code #6054

Merged
merged 5 commits into from
May 9, 2024
Merged

Conversation

Sahejkm
Copy link
Contributor

@Sahejkm Sahejkm commented May 8, 2024

Description

Replace .keyCode with .code to follow new MDN API

https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode#browser_compatibility

Closes: #6051

Copy link

vercel bot commented May 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 8, 2024 8:25am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 8, 2024 8:25am

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 8, 2024
Copy link

github-actions bot commented May 8, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
packages/lexical/dist/Lexical.js 23.73 KB (-0.06% 🔽) 475 ms (-0.06% 🔽) 112 ms (+138.16% 🔺) 586 ms
packages/lexical-rich-text/dist/LexicalRichText.js 34.33 KB (+0.14% 🔺) 687 ms (+0.14% 🔺) 259 ms (+75.49% 🔺) 945 ms
packages/lexical-plain-text/dist/LexicalPlainText.js 34.35 KB (+0.15% 🔺) 687 ms (+0.15% 🔺) 238 ms (+60.33% 🔺) 925 ms

Sahejkm added 2 commits May 8, 2024 15:14
This reverts commit 7fe6504.
Copy link
Member

@zurfyx zurfyx left a comment

Choose a reason for hiding this comment

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

I feel like this is correct but the size regression of including all the strings as opposed to numbers is noticeable (comparable to the discussion we had around coalescent operator). I also don't think the deprecated API is going away anytime soon, just like everyone uses document.execCommand. But it would also help toward the task assigned...

Will leave it open for a bit to see if others have any opinions on this

@Sahejkm Sahejkm merged commit 6a33ccf into main May 9, 2024
45 checks passed
@thegreatercurve thegreatercurve deleted the deprecate_keycode_to_code branch May 15, 2024 16:20
@Daniel15
Copy link
Member

Daniel15 commented May 16, 2024

For historical reference (since I know we're already fixing this in #6110): This breaks non-QWERTY layouts (Workplace: https://fb.workplace.com/groups/lexicaldiscussion/posts/1950653992035669/) and the numpad enter key (https://fb.workplace.com/groups/lexicaldiscussion/posts/1950753535359048/), because the web platform assumes a QWERTY layout:

For example, the code returned is "KeyQ" for the Q key on a QWERTY layout keyboard, but the same code value also represents the ' key on Dvorak keyboards and the A key on AZERTY keyboards. That makes it impossible to use the value of code to determine what the name of the key is to users if they're not using an anticipated keyboard layout.

Probably safer to use key instead of code (e.g. https://github.com/Daniel15/Website/blob/master/Daniel15.Web/wwwroot/Content/not_an_easter_egg/secret.ts#L20)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants