Wemos D1: LCD and keypad

Hello everyone, I am new to the forum, enter because I have a problem programming a wemos d1
By the way, my apologies if something is not understood, my English is somewhat rusty.

So I tested each thing separately first, the lcd and the keypad and they work perfectly (looking the keypad on the serial monitor). But I'm trying to connect the two and although the keypad is shown on the serial monitor, I can't make it show it on the lcd.
Actually the lcd turns everything on fine in the void setup() but inside the loop and after char key = keypad.getKey(); command it just wont work.

I tried before that command (key = keypad.getKey()) send something and the lcd it shows it well, but after it doesnt do anything, so i dont know if they share something internally.

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
#define  ledPIN D10
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); 


const byte n_rows = 4;
const byte n_cols = 4;
 
char keys[n_rows][n_cols] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
 
byte colPins[n_rows] = {D5, D4, D3, D2}; // la conexion sería de izq a der del pin 11 al 5 y el 2, visto de frente 
byte rowPins[n_cols] = {D9, D8, D7, D6}; 
 
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, n_rows, n_cols); 
// para guardar variables 
char codigo[4];            //Cadena donde se guardaran los caracteres de las teclas presionadas
int cont=0;          //variable que se incrementara al presionar las teclas
int i=0;
char key;



 
void setup(){

 //LCD1602
 lcd.begin(16,2);
  lcd.setCursor(1,0);         
  lcd.print("Incubadora ITS");
  lcd.setCursor(3,1);         
  lcd.print("Datos en mm");
  Serial.begin(115200); 
//  pinMode(ledPIN, OUTPUT);  //definir pin como salida
  delay (2000);
}
 
void loop(){

  char key = keypad.getKey(); 
 /*
  digitalWrite(D10 , HIGH);   // poner el Pin en HIGH
  delay(100);                   // esperar un segundo
  digitalWrite(D10 , LOW);    // poner el Pin en LOW
*/

  if (key != NULL){
    Serial.print("Key pressed: ");
    Serial.println(key);
 

    lcd.clear();
    lcd.setCursor(1,0);         
    lcd.print("YAY");
    lcd.setCursor(3,1);         
    lcd.print("Yupiti");

 }
  
/*
  
  
  if (key != NULL){

 // lcd.init();
//  lcd.backlight();
 lcd.begin(16,2);
  lcd.setCursor(1,0);         
  lcd.print("YAY");
  lcd.setCursor(3,1);         
  lcd.print("Yupiti");
    codigo[cont]=key;          //se guarda caracter por caracter en el arreglo codigo[]
    delay (1000); 
    Serial.println(codigo[cont]);

  }
*/
  
/*
    char key = keypad.getKey();
  
  if (key != NULL)         //se evalúa si se presionó una tecla
    { 

    codigo[cont]=key;          //se guarda caracter por caracter en el arreglo codigo[]
    delay (1000); 
    writescrn ();
    Serial.println(codigo[cont]);
    cont=cont+1;
    i=i+1;   
    if(cont==4)
    { 
    cont = 0;
    i=0;   
    }
    delay (1000);
    } */

}

void writescrn (){
  
 //   Serial.println("writescrn");
    lcd.clear();
    lcd.setCursor(2,0);
    lcd.print("Medida (mm)");
    lcd.setCursor(3+i,1);
    lcd.print(codigo[cont]);    //se imprime en el puerto serie la tecla presionada

}