public void keyPressed(KeyEvent key)
    {
        switch (key.getKeyCode()) {
            case KeyEvent.VK_LEFT:
                nextDirection = 3;
                break;
                
            case KeyEvent.VK_RIGHT:
                nextDirection = 1;
                break;
                
            case KeyEvent.VK_UP:
                nextDirection = 0;
                break;
                
            case KeyEvent.VK_DOWN:
                nextDirection = 2;
                break;
        }
        
        if (!isMove) {
            setDirection(nextDirection);
            isMove = true;
        }
    }