JSFiddle - React, Tailwind, and code Playground
HTML
<textarea></textarea>
JavaScript
$('textarea').keyup(function(e) {
if(e.which == 13) {
var val = $(this).val(),
newval = val.replace(/\n{3,}/g, '\n');
if(val != newval) {
$(this).val(newval);
}
}
});