MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / getKeyAndMove

Function getKeyAndMove

assets/js/amongus/index.js:49–82  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

47
48// On Pressing the key [The Main function]
49function getKeyAndMove(e){
50
51
52
53// Fetching the key code value
54 var key_code=e.which||e.keyCode;
55 switch(key_code){
56 case 37: //left arrow key
57 moveLeft();
58 break;
59 case 38: //Up arrow key
60 moveUp();
61 break;
62 case 39: //right arrow key
63 moveRight();
64 break;
65 case 40: //down arrow key
66 moveDown();
67 break;
68 case 87: // W key
69 moveUp();
70 break;
71 case 83: //S key
72 moveDown();
73 break;
74 case 65: //A key
75 moveLeft();;
76 break;
77 case 68: // D key
78 moveRight();
79 break;
80 }
81
82 }
83
84// Code for moving Character
85function moveLeft(){

Callers

nothing calls this directly

Calls 4

moveLeftFunction · 0.70
moveUpFunction · 0.70
moveRightFunction · 0.70
moveDownFunction · 0.70

Tested by

no test coverage detected