// JS
document.querySelector('input').onchange = function(event) {
document.querySelector('code').textContent = event.target.value;
}
<input type="text">
Your typed texts appear here: <code></code>
<br><small>(hint: type anything in the text field and click out of the input to view the changes)