JSFiddle - React, Tailwind, and code Playground
HTML
<textarea></textarea>
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
JavaScript
$('textarea').keyup(function(e){
var e, s, l, t = this;
$(t).val( $(t).val().replace(/\r\n/g, '\r') );
s = t.selectionStart;
e = t.selectionEnd;
l = $(t).val().length;
$('ul')
.append('<li>Start = ' + s + ', End = ' + e + ', Length = ' + l + '</li>')
.find('li:first').remove();
});