I am making a car racing game in JavaScript. The car is controlled by the arrow keys. I have made a lot of games in JavaScript before and it worked.
The code I had used is:
function detectKey(e) {
var event = window.event ? window.event : e;
if (true) {
alert(event.keyCode)
}
}
Now I am using this code the first time for arrow keys. Whenever I press the arrow keys the the page is moving up and down. I am not understanding the problem. Can somebody help?