I am trying to add functionality, in which shift+enter can be used for a new line. But when I am adding it, the cursor goes to the starting position and also no newline added
<InputEmoji
value={text}
onChange={handleChange}
// onEnter={handleOnEnter}
placeholder="Type a message..."
onKeyDown={(e) => {
if (e.keyCode === 13 && e.shiftKey) {
var t = text + "<br/>";
handleChange(t);
//e.preventDefault();
setTimeout(() => {
//e.target.innerHtml += "<br/>"
const el = e.target;
const selection = window.getSelection();
const range = document.createRange();
selection.removeAllRanges();
range.selectNodeContents(el);
range.collapse(false);
selection.addRange(range);
el.focus();
}, 100);
}
else if (e.keyCode === 13) {
//console.log(text)
//e.preventDefault();
handleOnEnter(text)
}
}}
/>
Can u please suggest me a better approach for newline