@Override
    public void keyPressed(KeyEvent keyEvent) {
        int keyCode = keyEvent.getKeyCode();
        if (keyCode == KeyEvent.VK_LEFT) {
            moveLeft();
        } else if (keyCode == KeyEvent.VK_RIGHT) {
            moveRight();
        } else if (keyCode == KeyEvent.VK_DOWN) {
            moveDown();
        } else if (keyCode == KeyEvent.VK_UP) {
            rotate();
        } else if (keyCode == KeyEvent.VK_R) {
            restart();
        } else if (keyCode == KeyEvent.VK_S) {
            if (game.getState() == GameState.MAIN_MENU) {
                game.setState(GameState.PLAYING);
            }
        } else if (keyCode == KeyEvent.VK_P || keyCode == KeyEvent.VK_ESCAPE) {
            pause();
        }
    }