While working on a chatting application, I've encountered the following problem: For the user to write his messages, I have implemented a textarea through HTML, and when said user presses enter, it does indeed send the message, but it also adds a newline to said textarea. Can I add something to the end of my EventListener in order to remove the newline? Thanks. (Edit: I need to be able to send the messages with ENTER, but not have the effect of it on my textarea text). Here's my EventListener:
document.addEventListener('keydown', e => {
if (e.key == "Enter"){
send();
//solution goes here...
}
});
Setting the value of the textarea to "" doing TA.value = "";
didn't work.