I'm trying to build a game.
When I press the spacebar, it would trigger an event and fire some bullets
What I would like it to do is, constantly firing the bullets and not need to press on the spacebar.
Is there a function for this.
My alternate method is to use an infinite loop but this is bad programming.
Is there an alternate method??
Here's my code:
Code:function keyDown(e) { if (e.keyCode == 32) { alert("bow bow!!"); } } document.addEventListener("keydown", keyDown, false);


Reply With Quote
Bookmarks