I need a piece of code that detects key presses then performs a function. The code I've got works, but after the function has been triggered, whichever key is pressed, the function will run again.
var key = [];
onkeydown = onkeyup = function(e){
e = e || event;
map[e.keyCode] = e.type == 'keydown';
if(key[17] && key[16] && key[65]){ //CTRL+SHIFT+A
alert('Enabled');
enableControls();
key[];
return false;
}
}
I've set the array to nothing at the end with 'key[];', but this stops the whole function from even running when triggered in the first place. How can I run the function once when the keys are pressed but stop this bug that repeats the function regardless of which keys are pressed?