public void keyReleased(KeyEvent evt) {
        if ((evt.getKeyCode() == keys[UP]) && (direction == DIR_UP)) {
            direction = 0;
        }
        if ((evt.getKeyCode() == keys[DOWN]) && (direction == DIR_DOWN)) {
            direction = 0;
        }
        if ((evt.getKeyCode() == keys[LEFT]) && (direction == DIR_LEFT)) {
            direction = 0;
        }
        if ((evt.getKeyCode() == keys[RIGHT]) && (direction == DIR_RIGHT)) {
            direction = 0;
        }
    }