I'm practicing on keyboard events and I have the first four keys working properly but I cant make it work on the space tab. What it needs to do is to call the drawMine function at its given coordinates. What am I missing? Please see code below:
function keyDown(e) {
if (e.key == "ArrowDown" && truckY <= 300) {
truckY += 50;
} else if (e.key == "ArrowUp" && truckY >= 50) {
truckY -= 50;
} else if (e.key == "ArrowRight" && truckX <= 300) {
truckX += 50;
} else if (e.key == "ArrowLeft" && truckX >= 50) {
truckX -= 50;
} else if (e.key == " ") {
let mineX = 110;
let mineY = 110;
drawMine(mineX, mineY);
}