Game Development Reference
In-Depth Information
SPACEBAR_KEY: 32,
COMMA_KEY: 188,
PERIOD_KEY: 190
};
var wordsLen = wordsWritten.children.length;
// If the Shift key was entered, just ignore
it
if (event.keyCode == keyCodes.SHIFT_KEY)
return false;
// If the backspace key was entered, don't
let thebrowser navigate away
if (event.keyCode == keyCodes.BACKSPACE_KEY) {
event.preventDefault();
// If we have deleted every letter entered
by the user,don't do anything else
if (wordsLen < 1)
return false;
// If the user has pressed the backspace
key, andthere is at least one letter
// that the user had typed in before,
delete thatletter from where it was output.
// Note that some browsers might not
supportthe .remove() function on a node,
// but rather use the removeChild()
function onthe node's parent element.
wordsWritten.children[wordsLen -
1].remove();
return false;
}
// Determine what character the user has
typed in
var letter =
Search WWH ::




Custom Search