Change delay/running time by keypad

I suspect you are making life difficult for yourself by not planning the program so that the the overall logic is separate from the details.

I would make my loop() like this

void loop() {
readKeypad();
updateLCD();
checkValidNumber();
actOnValidNumber();
}

There would need to be an array to hold the characters that are entered - so the array might first be 3----, then 35---, 356-- etc as the characters are entered (assuming you want 5 digits). This would happen in the readKeypad() function.

The updateLCD() function would just display whatever happens to be in the array of characters.

The checkValidNumber() function would be watching to see if all 5 characters are entered. When they are it would set a variable that tells the readKeypad() function not to accept any more data for the moment

The actOnValidNumber() function would do whatever it should only if there was a complete number to work with.

The important thing is that each of the functions completes its task very quickly so that loop() can repeat as fast as possible.

Have a look at planning and implementing a program

...R