Stack overflow answer

by Julien Etienne

HTML

<input placeholder="Enter some text" name="name"/>
<p id="values"></p>

JavaScript

const input = document.querySelector('input');
const log = document.getElementById('values');

input.addEventListener('key', updateValue);

/* function updateValue(e) {
console.log(e)
const { value } = e.target
const lastValue = [...value][value.length - 1]
  log.textContent = lastValue */
}