I am trying to get the key pressed inside a div. But I am not sure how to just get the key pressed. Currently as I try to press the key nothing happens.
The way I am doing is.
<div contenteditable="true" id="d"> </div>
<p id="log"></p>
const input = document.querySelector('input');
const log = document.getElementById('log');
document.getElementById("d").addEventListener("onkeyup", logKey)
function logKey(e) {
log.textContent += ` ${e.code}`;
}
Here is also the jsfiddle corresponding to it: https://jsfiddle.net/hpeLqmyg/
How could I do this?