I'm currently building a Tron canvas game based on this code. it works kinda good, but if I restart the game, two values are getting passed via e.which.
Try to show main code:
function loadGame() {
var e;
document.onkeydown=function(event){e=event};
function intervall() {
function check() {
//Function for drawing Tron
}
var key = e.which;
if(key == 87) { //W and so one
check();
}
}
var timer = setInterval(intervall,900)
}
If I lose, and call loadGame() again, it works great. It does not if I call loadGame() while Game is still running.
I uploaded a live demo here: http://wernersbacher.de/tron.html
Thanks for any help!