Description

Enter key is used to insert a line break into the editable area. This default behavior could be altered by the context of current selection, type of the content or a modifier key pressed along the Enter key.

User Expectations and Popular Behavior

User expects that:

  • Pressing the Enter key would create a new block of text.
  • Pressing the Shift+Enter combination would break a line of text without creating a new block of text.
  • The default behavior, defined above, differs when the current selection is in non-paragraph context (e.g. inside heading or list).

Block context

When the Enter key is pressed inside a block context, it MUST produce the new block context. If the type of the new block context is not specified by a certain feature, the new block context MUST be a paragraph context and MUST be created by inserting the new p element[1] into the current selection position.

When the Shift+Enter combination is pressed inside a block context, it MUST produce the new line break, by inserting the new br element[2] into the current selection position.

Non-block contexts

If the current selection position does not allow block context, pressing the Enter key or pressing the Shift+Enter combination MUST produce the new line break, by inserting the new br element[2].

If the current selection position does not allow block context and does not allow the br element, pressing the Enter key or pressing the Shift+Enter combination MUST be disabled.

Notes

  • The behavior of the Enter key and the Shift+Enter combination, defined above, SHOULD NOT be altered.

References

  1. The p element definition in the HTML5 standard.
  2. The br element definition in the HTML5 standard.