Getting a 4-digit number from a keypad

Hello,
I have modified the code, but the result is the same:

#include <Keypad.h>

int i = 0;
int choice;
int myInt =0;
int myNum[]={0,0,0,0};
int total = 0; 

const byte ROWS = 4; 
const byte COLS = 4; 
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {49,48,47,46}; //connect to row pinouts 
byte colPins[COLS] = {45,44,43,42}; //connect to column pinouts

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

void setup(){
                                    
  Serial.begin(9600); 
}

void loop()
{
  
Serial.println("Enter four-digit num -");  // request for input
            
for (int i = 0; i < 4;){
while(keypad.getKey() == NO_KEY)
{
    // Do nothing
}
if(keypad.getKey()!= NO_KEY);
{                
 char key = keypad.getKey();
 int myInt = key;
 Serial.println("You have pressed ");
 Serial.print(key);
 Serial.println("The corresponding number is ");
 Serial.print(myInt);
 myNum[i]= myInt;
 i = i+1;
}
}

 Serial.println();             
 Serial.print("Entered number is = ");
  
        Serial.print(myNum[0]);
        Serial.print(myNum[1]);
        Serial.print(myNum[2]);
        Serial.println(myNum[3]);
       
        total = (myNum[0]*1000)+(myNum[1]*100)+(myNum[2]*10)+(myNum[3]); 
        
        delay(500);
        
        Serial.println(total);
}

Thank you very much jasit for the idea of printing through the way :slight_smile:
The print of the key pressed shows a blank space and the print of the number, of course, zero.
Also this code waits for four keys to show the string and the total.
If I change the line:

 int myInt = key;

for:

 int myInt = key-'0';

The key printed still is the blank space and the number -48. So the problem is that doesn´t recognizes the keypad in this code... But recognizes in the other codes I have made...

¿What is wrong?

Cheers