So I got a textfield I use for a small chat program, and I let the chat send whatever is in a textfield by capturing the keydown event and sending the content of the textfield whenever enter is pressed. Problem is: Enter for some reason places a whitespace at the place where the user was last writing, so if the user clicks somewhere into the middle of the text in the textfield and then presses enter the message gets sent with a whitespace in the middle of it, which is very annoying…
Any solutions?
So I got a textfield I use for a small chat program, and I
Share
Use of preventDefault on enter will not allow any space in text area.
HTML:
JS: