BLACKJACK
Code Explanation
event.preventDefault(); Stops other key responses
} Close clause
switch(keyCode) { Header for the switch statement
based on keyCode
case 68: d key has been pressed down
deal(); Deals out another card to the player
and maybe to the dealer
break; Leaves the switch
case 72: h key has been pressed down
playerdone(); Invokes the playerdone function
break; Leaves the switch
case 78: n key has been pressed down
newgame(); Invokes the newgame function
break; Leaves the switch
default: Default choice, which may be
appropriate to remove if you dont
feel the need to provide feedback to
players if they use an unrecognized
key
alert("Press d, h, or n."); Feedback message
} Closes the switch
} Closes the function
function dealstart() { Header for the function for initially
dealing cards
playerhand[pi] = dealfromdeck(1); Gets the first card for player