JSFiddle - React, Tailwind, and code Playground
HTML
<div id="editor" contenteditable="true" style="border:1px solid #000; width:500px; height:200px;">
<p><span class="name">content</span></p>
</div>
<div id="before" style="border:1px solid blue; width:500px; height:100px;"></div>
<div id="afterEnterKeyPressed" style="border:1px solid red; width:500px; height:100px;"></div>
JavaScript
$('#editor').on('keyup', function(e) {
var keyCode = e.keyCode;
if (keyCode === 13) {
$('#afterEnterKeyPressed').text($('#editor').html());
}
});
$('#before').text($('#editor').html());