I have a system where once a certain key is pressed, a Boolean changes to true and the program should trigger an if loop. However, once the key is pressed, the program 'locks up' and is unresponsive. (The program should be automatically moving the paddle, and the whole thing should be able to be turned off, but it seems as though it simply isn't activating. Here's the offending code:
var aienable = false;
$(document).keydown(function(keyPressed){
if (keyPressed.keyCode == 192 && aienable == false){
aienable = true;
}
});
if (aienable == true){
var AIdrive = setInterval(function(){
$(document).keydown(function(keyPressed){
if (keyPressed.keyCode == 192 && aienable == true){
aienable = false;
}
});
if (aienable == false){
clearInterval(AIdrive);
}
},1000);
}
Note: The key used is `
Aucun commentaire:
Enregistrer un commentaire