Delete the contents of a text area while retaining line breaks
<p>In HTML/JS, I have a script that when the enter key is pressed, it copies the text from the <code>textarea</code> and then deletes the text. The problem is, after deleting the text, the line breaks for the enter key are still there. My code is as follows: </p>
<p><br /></p>
<pre class="brush:js;toolbar:false;">function Send() {
let lastText = document.getElementById("textInput").value;
document.getElementById("sent").innerHTML = lastText;
document.getElementById("textInput").value = "";
}
functionKeyDetection(event) {
let key = event.key;
if (key == "Enter") {
Send()
}
}</pre>
<pre class="brush:html;toolbar:false;"><textarea
id = "textInput"
class = "textInput"
rows = "1"
cols = "50"
placeholder = "write here"
onkeydown = "KeyDetection(event)"></textarea>
<p id = "sent"></p></pre>
<p><br /></p>
<p>I tried using null and empty string. I was hoping it would remove the newlines produced by pressing the enter key, but with no success. </p>