Several tasks at the same time in loop()

Good evening,

I'm looking in a main loop to test several values at the same time:
the value of a fingerprint sensor (finger()...), a keypad (alarm, pave_num()) and a force sensor (scale.getGram() which tests in grams an effort)
If the fingerprint sensor and keypad are ok I activate the cylinder opening (no problem)
But as soon as I add while(scale.getGram() >= 15 (kg)) my fingerprint sensor slowed down and I have trouble entering the password on the keypad....
Therefore I would like to execute these two conditions at the same time.
void loop()
{

fingerprintID = getFingerprintIDez();
alarm = pave_num()

if (finger.fingerID == 1 and alarm == 0)
{
Serial.println("MALLETTE UNLOCK");
cylender_S();
delay(1000);
cylender_R();
}

while (scale.getGram() >= 15)
{
pump();
}

}

Thank you in advance;)

It would help to see all your code. I'd suggest moving to a state-machine style of execution but without seeing your actual code it's hard to know if that would be suitable.

  while (scale.getGram() >= 15)
    {
        pump();
    }

Get rid of the while statement. Turn the pump on when the scale reads above the value. On every pass through loop(), see if the pump still needs to be on. If not, turn it off.

Have a look at how the code is organized in Several Things at a Time

Note how each function runs very briefly and returns to loop() so the next one can be called. None of the functions tries to complete a task in one call. And there may be dozens of calls to a function before it is actually time for it to do anything.

...R