Created
May 15, 2014 14:13
-
-
Save natekandler/370f3d5655cc43c36190 to your computer and use it in GitHub Desktop.
JS racer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var counter1 = 0 | |
var counter2 = 0 | |
$(document).ready(function(){ | |
var $player1 = $("#player1_strip"); | |
var $player2 = $("#player2_strip"); | |
$(document).keyup(function(event){ | |
// event.which for keyup will return the ascii value for the key that was pressed | |
if (event.which === 80){ | |
$($player1.children()[ counter1 ]).html("") | |
counter1++ | |
$($player1.children()[ counter1 ]).html("car") | |
} | |
else if (event.which === 81){ | |
$($player2.children()[ counter2 ]).html("") | |
counter2++ | |
$($player2.children()[ counter2 ]).html("car") | |
} | |
}); | |
}) ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment