-
Notifications
You must be signed in to change notification settings - Fork 0
/
keypress.js
43 lines (41 loc) · 1007 Bytes
/
keypress.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
window.addEventListener("keydown", checkKeyPress, false);
var left = document.getElementById("left").value;
function checkKeyPress(e) {
switch (e.keyCode) {
case 65:
currentTetrimino.moveLeft();
drawGameBoard();
break;
case 87:
rotateCurrentTetrimino()
break;
case 68:
currentTetrimino.moveRight();
drawGameBoard();
break;
case 83:
moveDownAndCheck();
break;
case 96:
rotateCurrentTetrimino()
break;
case 32:
moveDownAndCheck();
break;
case 103:
location.reload();
7
break;
case 104:
playSound();
break;
case 105:
clearInterval(gameInterval);
tetrisMusic.pause();
break;
case 101:
gameStart();
playSound();
break;
}
}