I need help with a keyboard event. So what i want to happen is when you press the w and the 2 key i want to add one to water instead of one to wood (as an alternative when pressing the w key without the 2 it will add one to wood. But i only want the wood and the water to update once instead of adding one when you hold down the key. heres some code
var wood = 0;
var water = 0;
var woodOut = document.getElementById('wood');
var waterOut = document.getElementById('water');
window.addEventListener("keydown", key);
function key() {
var x = event.which || event.keyCode;
if(x == 87){
wood = wood + 1;
woodOut.innerHTML = wood;
}
if(x == 87 && x == 50){
water = water + 1;
waterOut.innerHTML = water;
}
}
<p id="wood">0</p>
<p id="water">0</p>