To detect "shift+enter" and generate a new line in text area with JavaScript, we check the keys pressed in the keyup event handler.
For instance, we write
if (event.keyCode === 13 && event.shiftKey) {
console.log("Shift+Enter key Pressed");
}
to check if enter is pressed by checking if keyCode
is 13.
And we check if shift key is pressed with shiftKey
.
If both are true, then shift+enter is pressed.