Keypad read & enter a string.

Hello,
I’m trying to use the 4x4 keypad to input more than one character and then press “*” to enter and display the string. Also “#” to reset or “C” to clear.
I am using an I2C (20x4) LCD to display the string typed in by the keypad. Right now it only displays one character and overwrites sequential characters.
Looking to use “int number” to store one or more characters before entering.

I’m looking for a simple example for the keypad as I found a simple example to read the serial monitor from a key board.
.
To read the serial monitor input:
while (Serial.available()==0) {} //Waiting for user input
number = Serial.parseInt(); //Read the string

How is this done using a keypad/LCD? I realize the serial monitor feature has code to “send” built in.

I’ve seen a few examples on inputting passwords by keypad and they appear to be overly complicated (at least at my level of programming).

The attached code is a modified version of one of the keypad library examples.

Thank you for any input.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'},
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad  (+3) for nano
byte colPins[COLS] = {9, 8, 7, 6}; //connect to the column pinouts of the keypad (+3) for nano

int number;

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity

void setup()
{  
  lcd.begin(20,4);
  lcd.backlight();
  lcd.setCursor(0, 0); 
  lcd.print("You pressed: ");
  lcd.setCursor(0, 2); 
  lcd.print("Press C to clear");
  
}
  
void loop(){
  
  char key = keypad.getKey();
   keypad.getKey();
   delay(30); //debounce keypad
 
  if (key){
   
    lcd.setCursor(0, 0); 
    lcd.print("You pressed: ");
    lcd.setCursor(13, 0);
    lcd.print(key);
                         
  if (key == '*')    //To Enter Number   
   {
    lcd.setCursor(0, 1);   //set to row 2
    lcd.print("Pressing * = Enter");
   }
                  
  if (key == '#')   //To reset Number
  {
    lcd.setCursor(0, 1); 
    lcd.print("Pressing # = Reset");
  }
  
  if (key == 'C')   //Clear first row char & second row when C is pressed
  {
    lcd.setCursor(13, 0); 
    lcd.print("       ");
    lcd.setCursor(0, 1); 
    lcd.print("                   ");  //20 spaces
  } 
 }
}
  char key = keypad.getKey();
   keypad.getKey();
   delay(30); //debounce keypad
 
  if (key){
   
    lcd.setCursor(0, 0); 
    lcd.print("You pressed: ");
    lcd.setCursor(13, 0);
    lcd.print(key);

Why the two keypad.getKey() calls, one of which does not store the input ?
Why do you put the cursor back to 0, 0 each time a key is pressed ?

How is this done using a keypad/LCD?

The if (key) test will tell you whether a key has been pressed.
There is no equivalent to parseint in the keypad library as far as I know, you have to do it yourself. Read the keyboard, if the character input is a number put the character into an array. Keep going putting the characters in the array until you receive the "Enter" character then terminate the array with a zero and use the atoi() function to get an integer from the character array.