document.addEventListener('keydown', function(e){ if(e.keyCode === 87) { world.style.transform = "translateZ(+1); } }); code example
Example 1: javascript keydown
document.addEventListener("keydown", function(event) {
if (event.keyCode == 32) {
console.log("Space was pressed!");
}
});
Example 2: event listener for keydown
eventTarget.addEventListener("keydown", event => {
if (event.isComposing || event.keyCode === 229) {
return;
}
// do something
});