When the user writes anything in a textarea, and when pressing the enter button to moving to a new line, there is a character created '\n'
.
What about if the user continued to write until he got to the end of the line, and then turn in to a new line automatically without pressing the enter button, in this case how can I to know this ?
The following code Will increase the textarea when press the enter button, and I want to doing the same behavior when automatically turn in to a new line without press the enter button:
var textarea = document.getElementById('text');
textarea.onkeyup = function (eve) {
if (eve.keyCode == 13) { // 13 = enter key
textarea.style.height = textarea.offsetHeight + 25 + 'px';
}
};
#text {width:300px;}
<textarea id="text"></textarea>