Break line by pressing Enter and Shift + Enter

Asked

Viewed 76 times

1

I have an input, and I need it to break line by pressing Enter and Shift + Enter, and only send the message by clicking the button. But he doesn’t break the line

 handleChatInputPress = (e) => {
if ((e.key === "Enter" && e.shiftKey) || e.key === "Enter") {
  return "\n";
} else {
  this.handleSendButtonClick();
}


 return (
  <div className="chat-input-container d-flex justify-content-between align-items-center">
    <Input
      className="form-control flex-grow-1"
      type="text"
      placeholder={placeholder}
      value={messageInput}
      onKeyPress={(e) => {
        if (enableSendMessage) {
          handleChatInputPress(e);
        }
      }}
      onChange={(e) => handleChatInputChange(e)}
    />
    <div>
  • 4

    Inputs do not support line breaks even, will what you are looking for is not a textarea?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.