-
Notifications
You must be signed in to change notification settings - Fork 22.6k
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
Document that the Enter key causes the “keypress” event to fire #37817
Conversation
Preview URLs External URLs (1)URL:
(comment last updated: 2025-01-30 07:33:55) |
Wait, but doesn't Enter also produce a printable character, i.e. the line break character? Is that not always the case? |
103abd4
to
a2add09
Compare
Good point — the existing “key that produces a character value” language doesn’t actually have any clear and precise technical meaning. It’s ambiguous and misleading and unhelpful and we never should have been using it to begin with. What the spec actually normatively defines it as is, “belonging to the set of valid Unicode character categories”, where Unicode character categories is this:
So, I’ve amended the commit to excise the “key that produces a character value” language and instead — to match the actual normative spec requirements — explicitly and precisely just say, “a letter, number, punctuation, or symbol key”. |
Thanks! It's actually fine if you refer to those Unicode character categories explicitly, and link to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape. Makes the definition even less ambiguous. |
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.
a2add09
to
703cb5c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
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.keypress
event should be fired w3c/uievents#266 (comment)Otherwise, without this change, the information on the
keypress
page incorrectly doesn’t match actual browser behavior — in that the page states that thekeypress
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.