How to "Jog" stepping motor by holding keypad key down

I’d like to use a keypad button to jog my stepping motor, but I’m having trouble.
What I want is to hold down a key on a keypad and have the motor step until I release the key.
I’m guessing this not an uncommon piece of code, but I haven’t been able to find a good example of how to do it.
I have been able to get two unacceptable results.
In the following case, I press the key once and it runs off for several minutes like I’ve pressed the key 1k times. I assume the keypad is registering many presses and queuing them up.

void loop(){
  char key = keypad.getKey();
      while(key == 'B') {
      for (int i=1; i <= 10; i++){
        digitalWrite (step_pin, HIGH) ;
        delayMicroseconds (10) ;
        currentPosition = currentPosition - 1;
        digitalWrite (step_pin, LOW) ;
        delayMicroseconds (100) ;
      }
      Serial.print("position = ");
      Serial.println(currentPosition);
    }
}

if I use an if instead of a while, then the code gets executed only once despite holding it down. I realize that’s the probably the correct behavior for the kepad library:

void loop(){
  char key = keypad.getKey();
      if(key == 'B') {
      for (int i=1; i <= 10; i++){
        digitalWrite (step_pin, HIGH) ;
        delayMicroseconds (10) ;
        currentPosition = currentPosition - 1;
        digitalWrite (step_pin, LOW) ;
        delayMicroseconds (100) ;
      }
      Serial.print("position = ");
      Serial.println(currentPosition);
    }
}

I tried the keypad event but no better results. The following would wait the appropriate time after holding the key down and execute the step loop only once:

void keypadEvent(KeypadEvent key){
  switch (keypad.getState()){
  case PRESSED:
     break;

  case RELEASED:
    break;

  case HOLD:
    if (key == 'B') {
      for (int i=1; i <= 10; i++){
        digitalWrite (step_pin, HIGH) ;
        delayMicroseconds (10) ;
        currentPosition = currentPosition - 1;
        digitalWrite (step_pin, LOW) ;
        delayMicroseconds (100) ;
      }
      Serial.print("position = ");
      Serial.println(currentPosition);
    }
    break;
  }
}

Would someone point me in the right direction?
Thanks,
Bernn

I have no knowledge of the keypad library but I would have expected your IF version to work.

Have you checked what value is produced by keypad.getKey() when you hold the key down while doing a series of getKey()s - maybe it only returns the key on the first read?

...R