Skip to content

Instantly share code, notes, and snippets.

@BlueMagnificent
Created August 3, 2020 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BlueMagnificent/16a6dde3d0f83159035b33025df25b13 to your computer and use it in GitHub Desktop.
Save BlueMagnificent/16a6dde3d0f83159035b33025df25b13 to your computer and use it in GitHub Desktop.
Javascript 3D Physics Tut 3 Handle Key Down
function handleKeyDown(event){
let keyCode = event.keyCode;
switch(keyCode){
case 87: //W: FORWARD
moveDirection.forward = 1;
break;
case 83: //S: BACK
moveDirection.back = 1;
break;
case 65: //A: LEFT
moveDirection.left = 1;
break;
case 68: //D: RIGHT
moveDirection.right = 1;
break;
case 84://T
checkContact();
break;
case 74://J
jump();
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment