Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

LibWeb: Fire keypress event for Enter, Shift+Enter, and Ctrl+Enter keys #3353

Merged

Conversation

sideshowbarker
Copy link
Contributor

@sideshowbarker sideshowbarker commented Jan 24, 2025

For web compat and interop with other engines, this change makes us fire keypress events for the Enter key and for the combination of the Enter key with the Shift or Ctrl keys — despite the fact the UI Events spec states at https://w3c.github.io/uievents/#event-type-keypress it must be fired “if and only if that key normally produces a character value”.

See w3c/uievents#183 (comment) and w3c/uievents#266 (comment).

Otherwise, without this change, Ladybird won’t work as expected in (the likely very many) existing web applications that use the keypress events to check for Enter key presses.

For example, without this change, Ladybird doesn’t work as expected when trying to send messages in the https://thelounge.chat/ web-based IRC client (which is where I first noticed this problem), and generally perhaps in many Vue-based apps — because the Lounge is a Vue-based app, and https://github.com/search?q=%22%40keypress.enter%22+language%3AVue&type=code&l=Vue seems to indicate there’s a whole lotta other existing Vue code out there in the wild that’s doing stuff with @keypress.enter

For web compat and interop with other engines, this change makes us fire
“keypress” events for the Enter key and for the combination of the Enter
key with the Shift or Ctrl keys — despite the fact the UI Events spec
states at https://w3c.github.io/uievents/#event-type-keypress it must be
fired “if and only if that key normally produces a character value”.

See w3c/uievents#183 (comment)
and w3c/uievents#266 (comment).
Copy link
Contributor

@Gingeh Gingeh left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

(I personally wouldn't restrict the modifiers just because I'm lazy, but I don't think that's worth amending)

@AtkinsSJ AtkinsSJ merged commit 738cb24 into LadybirdBrowser:master Jan 31, 2025
7 checks passed
@sideshowbarker sideshowbarker deleted the keypress-fire-for-Enter-key branch January 31, 2025 14:43
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants