Program Will Not Re-Start at the Very Beginning

I would like to know what I did wrong. I have a program that runs on an Arduino Mega 2560 that operates a 2 axis robot. It runs well in automatic mode but I added a manual mode component that works but not quite as I expected.

At the very beginning of the auto program, I looked for a 4 by 4 key pad ‘#’ key press and if so the program moves to several options to run in manual mode. If not, it will time out and continue into automatic mode.

The problem is that if I let it time out and continue, when the auto program runs its course, it should start over at the beginning but it re-starts right after the look for key press. By the same token, if I do enter manual mode and go back to auto, the same thing happens. It runs through the auto program but does not look for any key press at the beginning like I would expect.
Why not and how can I fix it? My void loop is posted below.

For general information:
This is what the program does but is probably not important for this discussion.
http://forum.arduino.cc/index.php?topic=201544.0 reply #13 I was asking for some guidance that was more general there.
http://forum.arduino.cc/index.php?topic=204526.msg1512197#msg1512197 reply #28 has the layout and the code for my manual input program that I incorporated into my auto program. It has had a few features add since this so it is a little out of date. Again, I thing that what I am doing wrong is probably pretty straight forward and a common mistake.

void loop()
{
  clearLCD();
  lcd.setCursor(0,0);   
  lcd.print("Press # to enter");
  lcd.setCursor(0,1);     
  lcd.println(" Manual   Mode  ");         
  Serial.println(String("BEGIN keyTime is ") + int(keyTime) + String(" before key 'for' loop"));  

while(keyTime <= 3000)
  {
  //Serial.println(String("Read ") + int(keyTime) + String(" inside key 'for' loop"));  
  keyPadFunction();
  //Serial.println("returned from keyPadF");
  delay(5);
  keyTime = keyTime + 1;
  }
clearLCD();
  Serial.println("Left 'for' to keyPadF");

  digitalWrite(optOutPin1,HIGH);                   // Turn on pin for Home senser
  digitalWrite(optInPin1,HIGH);                    // Turn on pullup resistors
  digitalWrite(optOutPin2,HIGH);                   // Turn on pin for All Stop Sensor
  digitalWrite(optInPin2,HIGH);                    // Turn on pullup resistors
  digitalWrite(optOutPin3,HIGH);                   // Turn on pin for Boom Up senser
  digitalWrite(optInPin3,HIGH);                    // Turn on pullup resistors 

//opticalSensor1 = digitalRead(optOutPin1);

  Serial.println("Pre-Start UP");
  lcd.setBacklight(TEAL);
  
onStartUp();   //<<************************  // Re-set the system when it starts or re-starts

  lcd.setBacklight(WHITE);
//lcd.clear();
  lcd.setCursor(9,0);
  lcd.print("                ");
  lcd.setCursor(9,1);
  lcd.print("                ");
  
     int stationReadOut;                           // Added so that stationNumber will read correctly
      for (int stationNumber = 0; stationNumber < stationCount; stationNumber++)
          {
             stationReadOut = stationNumber + 1;

             const int stepsToNextStation = distance[stationNumber];
             const int timeForFoodPumping = fTime[stationNumber]; 
             const int timeForWaterPumping = wTime[stationNumber];

             lcd.setCursor(0,0);                   // Upper row (0), character 1 (0)
             lcd.print("Station:");
             lcd.print(stationReadOut);
             
raiseTheBoom;
boomCheck();

             lcd.setBacklight(GREEN);             
             moveToNextStation(stepsToNextStation, DIR);
             lcd.setBacklight(WHITE);            

             lcd.setCursor(9, 1);
             lcd.print(totalSteps);

             extendAndFeed(timeForFoodPumping,timeForWaterPumping);
            
          }
      goHome();     
}

You never reset Keytime, so on the second iteration around loop, the while loop is ignored.

Think you. How do I do that.

keyTime = 0;?

Wow I'm sorry that I missed that! You have no idea how much grief I have encountered over this point. This applies to several of my issues. Thanks!!!!!!!