CHAPTER 10
Code Explanation
ctx.fillStyle = "blue"; Sets the color
builddeck(); Invokes the function to build the
deck of cards
back.src ="cardback.png"; Specifies the image for the back of
card (note that only one back
appears: the dealers hidden card)
canvas1 = document.getElementById('canvas'); Sets the variable for event handling
window.addEventListener('keydown',getkey,false); Sets up event handling for keydown.
presses
shuffle(); Invokes the function to shuffle
dealstart(); Invokes the function to deal out the
first four cards
} Closes the function
function getkey(event) { Function to respond to keydown
events
var keyCode; Holds the code designating the key
if(event == null) Browser-specific code to determine
if the event is null
{ Open clause
keyCode = window.event.keyCode; Gets the key code from
window.event.keyCode
window.event.preventDefault(); Stops other key responses
} Close clause
else { clause
keyCode = event.keyCode; Picks up the key code from
even.keyCode