JSFiddle - React, Tailwind, and code Playground

HTML

<textarea rows="4" cols="100" name="postcontent" onfocus="htmlHelper()" id="postcontent" required></textarea><br />

JavaScript

$(document).ready(function(){
	$("#postcontent").keypress(function(e) {
    if(e.which == 13) {
        //var currentHTML = document.getElementById("postcontent").value;
        //var currentHTML = currentHTML + "\n<br /><br />"
        //document.getElementById("postcontent").value = currentHTML;
        
    var cursorPos = $('#postcontent').prop('selectionStart'),
    v = $('#postcontent').val(),
    textBefore = v.substring(0,  cursorPos ),
    textAfter  = v.substring( cursorPos, v.length );
    $('#postcontent').val( textBefore+ "<br />" +textAfter );


    }
});
});