-
Notifications
You must be signed in to change notification settings - Fork 51
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
Fire keypress event for Enter, Shift+Enter, and Ctrl+Enter keys #392
Open
sideshowbarker
wants to merge
1
commit into
main
Choose a base branch
from
sideshowbarker/keypress-fire-for-Enter-key
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For web compat and interop with actual behavior in browsers, this change updates the spec to require firing “keypress” events for the Enter key and for the combination of the Enter key with the Shift or Ctrl keys. Otherwise, without this change, the spec is restricting implementations to requirements for keypress that are different from what browsers need to implement in order to be compatible with existing web content.
sideshowbarker
added a commit
to mdn/content
that referenced
this pull request
Jan 27, 2025
This change updates the page for the “keypress” event to match actual behavior in browsers — by changing the page to state that the event fires when the Enter key is pressed — not only when a key that produces a character value is pressed. See w3c/uievents#183 (comment) and w3c/uievents#266 (comment) and w3c/uievents#392 Otherwise, without this change, the information on the “keypress” page incorrectly doesn’t match actual browser behavior — in that the page states that the “keypress” event fires _only_ when a key that produces a character value are pressed, while in fact browsers also fire the event when the Enter key is pressed.
sideshowbarker
added a commit
to mdn/content
that referenced
this pull request
Jan 30, 2025
This change updates the page for the “keypress” event to match actual behavior in browsers — by changing the page to state that the event fires when the Enter key is pressed — not only when a key that produces a character value is pressed. See w3c/uievents#183 (comment) and w3c/uievents#266 (comment) and w3c/uievents#392 Otherwise, without this change, the information on the “keypress” page incorrectly doesn’t match actual browser behavior — in that the page states that the “keypress” event fires _only_ when a key that produces a character value are pressed, while in fact browsers also fire the event when the Enter key is pressed.
sideshowbarker
added a commit
to mdn/content
that referenced
this pull request
Jan 30, 2025
This change updates the page for the “keypress” event to match actual behavior in browsers — by changing the page to state that the event fires when the Enter key is pressed — not only when a key that produces a character value is pressed. See w3c/uievents#183 (comment) and w3c/uievents#266 (comment) and w3c/uievents#392 Otherwise, without this change, the information on the “keypress” page incorrectly doesn’t match actual browser behavior — in that the page states that the “keypress” event fires _only_ when a key that produces a character value are pressed, while in fact browsers also fire the event when the Enter key is pressed.
Josh-Cena
pushed a commit
to mdn/content
that referenced
this pull request
Feb 2, 2025
Document that the Enter key causes the keypress event to fire This change updates the page for the “keypress” event to match actual behavior in browsers — by changing the page to state that the event fires when the Enter key is pressed — not only when a key that produces a character value is pressed. See w3c/uievents#183 (comment) and w3c/uievents#266 (comment) and w3c/uievents#392 Otherwise, without this change, the information on the “keypress” page incorrectly doesn’t match actual browser behavior — in that the page states that the “keypress” event fires _only_ when a key that produces a character value are pressed, while in fact browsers also fire the event when the Enter key is pressed.
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For web compat and for interop with actual behavior in browsers, this change updates the spec to require firing
keypress
events for the Enter key and for the combination of the Enter key with the Shift or Ctrl keys.Otherwise, without this change, the spec is restricting implementations to requirements for
keypress
that are different from what browsers need to implement in order to be compatible with existing web content.As an example of a specific case where conforming to the current spec causes unexpected behavior:
Without this change, Ladybird — which has strictly implemented the spec as currently written — doesn’t work as expected when trying to send messages in the The Lounge • https://thelounge.chat/ web-based IRC client.
And in troubleshooting that problem, I noticed that The Lounge is a Vue-based app — so, out of curiosity, I did a search at https://github.com/search?q=%22%40keypress.enter%22+language%3AVue&type=code&l=Vue and found that there’s a whole lotta other Vue code out there in the wild that’s doing stuff with
@keypress.enter
.Closes #183, and closes #266.
The following tasks have been completed:
[There are existing errors; this change doesn’t introduce any new ones]
[I’m not aware of any WPT tests for this…]
Implementation commitment: