stepper motor control using button

int i = 0;
while (digitalRead(ButtonPin))
{
i++;  // how much the button has been held
}

How much what? Chocolate ice cream? That code is NOT measuring HOW LONG the switch was held down.