JSFiddle - React, Tailwind, and code Playground

HTML

<div id="box"><span id="cursor" class="blink">_</span></div>

CSS

#box {
  width : 200px;
  height: 100px;
  border: #000 1px solid;
  padding: 10px;
  font-family : monospace;
  cursor : text;
  word-wrap: break-word;
}
.hidden {
  visibility: hidden;
}

JavaScript

setInterval(function blink () {
  $('#cursor').toggleClass('hidden');
}, 600);

$(document.body).on('keypress', function(event) {
   $('#cursor').before(String.fromCharCode(event.keyCode));
});