JSFiddle - React, Tailwind, and code Playground

by TrueBlueAussie

HTML

<div class="one">
</div>

<textarea id="mainContent"  style="overflow:hidden">
    
</textarea>

CSS

.one{
    width: 100px;
    height: 30px;
    background: red;
}

textarea{ overflow: hidden;}

JavaScript

$('.one').hide();

$(function(){
    //hide show dive on enter press and on other keys hide div
$('#mainContent').on('keypress', function(e){
    $('.one').toggle(e.which == 13);
    TextareaAuto(this);
});

    function TextareaAuto(o) {
	    o.style.height = "200px";
	    o.style.height = (2+o.scrollHeight)+"px";
    }
    
    
});