Skip to content

Commit

Permalink
Fire keypress event for Enter, Shift+Enter, and Ctrl+Enter keys
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sideshowbarker committed Jan 24, 2025
1 parent 02207f8 commit 3d40610
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions sections/legacy-event-types.txt
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,17 @@ completeness.
</table>

If supported by a <a>user agent</a>, this event MUST be dispatched
when a key is pressed down, if and only if that key normally
produces a <a>character value</a>. The EVENT{keypress} event type is
device dependent and relies on the capabilities of the input devices
and how they are mapped in the operating system.
when a key is pressed down, if and only if any of the following
conditions are true:

- that key normally produces a <a>character value</a>
- that key is the KEYCAP{Enter} key and no modifier was active
- that key is the KEYCAP{Enter} key and the KEYCAP{Shift} modifier was active
- that key is the KEYCAP{Enter} key and the KEYCAP{Control} modifier was active

The EVENT{keypress} event type is device dependent and relies on the
capabilities of the input devices and how they are mapped in the
operating system.

This event type MUST be generated after the <a>key mapping</a>. It
MUST NOT be fired when using an <a>input method editor</a>.
Expand Down

0 comments on commit 3d40610

Please sign in to comment.