I am having a small problem on posting some text from a textarea as soon as the enter key is pressed.
The entered text gets appended to a div with a neat effect and the entered text is then removed from the textarea, which all works fine. However, when you hit enter a line break is actually still inserted in the textarea, right after which the text is appended and removed. So for a split second you can see the line break being added, which doesn’t look nice at all.
How do I prevent the insertion of a line break?
Thanks!
Dennis
UPDATE:
Some code here. I use the keyup.
$('#postDiv').on('keyup', '#posttext', function(e) {
if ((e.which == 13) && !event.shiftKey) {
post($(this));
}
});
Note the change to keydown, in order to block the default action