JSFiddle - React, Tailwind, and code Playground
HTML
<!-- Learn about this code on MDN: https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onkeyup -->
<div contenteditable="true" id="d">
</div>
<p id="log"></p>
CSS
#d {
width:50%;
color:red;
background-color: yellow;
}
JavaScript
const input = document.querySelector('input');
const log = document.getElementById('log');
document.getElementById("d").addEventListener("keyup", logKey)
function logKey(e) {
log.textContent += ` ${e.code}`;
}