program the buttons on a 4x4 keyboard

I use Mark Stanley keyboard library and Alexangre Brevid in my program for my 4x4 keyboard it works fine now I will add the following functionality:

| -----> Use one of the buttons to move the cursor to the left.
| -----> Another to move the cursor to the right.
| -----> Another to erase the entries.
| -----> Another to validate.
| -----> And another to clean the entire screen.

How can I do this?

Cordially!

Here is my code:

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

LiquidCrystal_I2C lcd(0x27,16,2); 


/*Le Clavier*/
const byte numRows= 4;
const byte numCols= 4;

char keymap[numRows][numCols]= { 
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
 };

byte rowPins[numRows] = {5,4,3,2};
byte colPins[numCols] = {9,8,7,6};

//initialiser le clavier
Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);
 
void setup() {
  //Initialiser l'ecran LCD
  lcd.init();
  lcd.backlight();
  SPI.begin();

  lcd.print("Entrez le");
  lcd.setCursor(0,1);
  lcd.print("montant");
  delay(3000);
  lcd.clear();
}

void loop() {
  char keypressed = myKeypad.getKey();

  if (keypressed != NO_KEY){
    lcd.print(keypressed);

  }
  
}

How can I do this?

Test the value of keypressed and execute the code for what you want to do, if anything, with each value would seem to be the obvious answer.

Where are you stuck ?

UKHeliBob:
Where are you stuck ?

Exactly I do not know the code corresponding to each feature I want

Use one of the buttons to move the cursor to the left.
When the key is detected, ‘subtract’ 1 from the current position, check to see if the cursor goes to the previous line.

Another to move the cursor to the right.
When the key is detected ‘add’ 1 to the current position, check to see if the cursor goes to the next line.

Another to erase the entries.
When the key is detected, make whatever variables = 0

Another to validate.
When the key is detected, proceed to the function() that does this.

And another to clean the entire screen.
When the key is detected, do a: lcd.clear();

Time for ‘you’ to study the examples that come with the library.

example:

void loop()
{
  char key = keypad.getKey();
    if (key)
  {
    Serial.println(key);
    if(key == ‘D’)
       {
            lcd.clear();  // clear the LCD
       }
  }
}