Skip to content

Unable to preventDefault the enter key on keydown #4806

@FabriceGaudin

Description

@FabriceGaudin

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

If I add an event handler on "keydown" which calls event.preventDefault() if it's the enter key (event.keyCode === 13), a breakline is added to the content (default behavior)

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via fiddle.tinymce.com or similar.

Here is a fiddle to reproduce: http://fiddle.tinymce.com/UAgaab

  • If you press Enter, a breakline is added
  • Then if you press the up arrow, the caret doesn't move.
  • In console, we can see that both events should have been prevented

What is the expected behavior?

If preventDefault is called during keydown of Enter, it shouldn't add a breakline.

Which versions of TinyMCE, and which browser / OS are affected by this issue? Did this work in previous versions of TinyMCE?

Spotted on 4.9.2 on Chrome and Firefox.
Reproduced on previous versions of TinyMCE until 4.0.22 (previously no event handler was possible)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions