Skip to content Skip to sidebar Skip to footer

Is There A Way To Make Enter And Shift + Enter Work The Same Way In Tinymce?

I'm using tinymce-react package in my current project. Is there a way to make 'enter' and 'shift + enter' work the same way? In my case I need them both to insert

Solution 1:

Are you looking for something like this?

//target textarea with querySelectorvar textA = document.querySelector("textarea");
textA.addEventListener("keyup", function(event) {
  // keyCode 13 is the "Enter" key on the keyboard// keyCode 16 is the "Shift" key on the keyboardif (event.keyCode === 13 || event.keyCode === 16) {
    // Prevent default action
    event.preventDefault();
    //if shift or enter are pressed then insert new paragraph
    textA.value = textA.value + "<p></p>"
  }
});
<textarea></textarea>

Post a Comment for "Is There A Way To Make Enter And Shift + Enter Work The Same Way In Tinymce?"