How to compare two integer passwords using array

int key[4];

or:

char key = kpd.getKey();

which key are you referring to?

 char key = kpd.getKey();
 for(i=0;i<4;i=i+1)

I'd go back to the keypad demo and try to get that working filling an array of size four.