The answer here.
There are two possible ways two retrieve the event key code:
event.keyCode or event.which
Your code should be:
$(document).keypress(function(event) {
var code = event.keyCode || event.which;
switch(code) {
case 38 : keyNorthPressed = true;
break;
case 39 : keyEastPressed = true;
break;
case 40 : keySouthPressed = true;
break;
case 41 : keyWestPressed = true;
break;
}
});
event.keyCode and event.which are attributes, not methods, you can't call them with a ().