Problem with multiple digits and wait for keypad

Hello I have a problem with my code :( can someone help my

First v1 works perfectly this is code:

Serial.print("Podaj godzine zapalenia swiatla:");
Serial.println("");
if (!Serial.available() > 0)

  {
    godzinaON = 0;
    while(1) {
      incomingByte = Serial.read();
      if (incomingByte == '\n') break;
      if (incomingByte == -1) continue;
      godzinaON *= 10;
      godzinaON = ((incomingByte - 48) + godzinaON);
    }
    Serial.println(godzinaON);
    EEPROM.write(0, godzinaON);
  }

But next i add keypad and write this

 int cyfra = 0;              // zerowanie cyfry
                    int klawisz = kpd.getKey(); // przypisanie zmiennej klawisz do klawisza
                    
                    Serial.print("Podaj godzine zapalenia lamp:");
                    Serial.println("");

                      if (klawisz == '#') 
                        {
                          cyfra = godzinaON;
                          Serial.println(godzinaON);
                          EEPROM.write(0, godzinaON);
                          cyfra = 0;  
                        }
                        else {
                              klawisz = klawisz - '0';  // turn an ascii character of a digit into a real number
                              cyfra = cyfra * 10;
                              cyfra = cyfra + klawisz;
                              }

and this not work :( what i need:

1: When serial prompt the message arduino wait for data from keypad 2: data is time so i need multiple digits like "21" or "2"

Can someone help my?

and this not work :( what i need:

The (snippet of) code does something. Therefore, it works. If it doesn't do what you expect, your expectations are wrong.

If you want to align what the code does to match your expectations, you need to tell us what the code actually does and what you expect it to do.

You also need to post ALL of it.

1: When serial prompt the message arduino wait for data from keypad

There is a method in the Keypad class to wait for a key. It is not getKey().

2: data is time so i need multiple digits like "21" or "2"

How is the Arduino supposed to know that sometimes you intend to enter one digit and sometimes two? The usual way is to just keep reading until some key is pressed that conveys "Done!", like a period at the end of a sentence or the carriage return/line feed at the end of a paragraph.

can you write this in a code? I speend all night and no sukcess :(

char przycisk = kpd.waitForKey();
  int liczba = 0;
  
  if (przycisk == '#'){
    Serial.println(liczba);
  }
  else {
    liczba = przycisk - 48;
  }

smotehing like that dont work :( pass loop after one click

smotehing like that dont work

Sure it did.

pass loop after one click

Why would you expect otherwise, when you wait for ONE key?

You need to pay a visit to the fine folks at http://snippets-r-us.com for help with snippets.