diff --git a/tetris-control.js b/tetris-control.js index d60340f..8693be3 100644 --- a/tetris-control.js +++ b/tetris-control.js @@ -9,9 +9,25 @@ function initControls() { function onKeyDown(e) { var ascii_space = 32; - + var ascii_left = 37; + var ascii_right = 39; + var ascii_down = 40; + var ascii_up = 38; + if (e.keyCode == ascii_space) { game.hardDrop(); + } else if (e.keyCode == ascii_left) { + game.moveCurrentBrickHorizontally(-1); + } else if (e.keyCode == ascii_right) { + game.moveCurrentBrickHorizontally(1); + } else if (e.keyCode == ascii_up) { + if (! wasRecentlyRotated) { + game.rotateCurrentBrick(); + wasRecentlyRotated = true; + } + return; + } else if (e.keyCode == ascii_down) { + game.moveCurrentBrickDown(); } }