Getting a 4-digit number from a keypad

one of the things I like to do is, setup a timer so that it will only wait for the 4 buttons to be press a set amount of time before it resets and goes back to waiting for the first key. Also you have a line int getKey(tmp); do a Serial.print of tmp before and after that to see what it is.

 int buttonpressed = 0;
     while(buttonpressed < 1){
       timer = millis();
       buttonState[thisPin] = digitalRead(buttonPins[thisPin]);
       buttonpressed += buttonState[thisPin];           
       }
       if(timer - mil > 10000) {buttonpressed = 1;}     
     }
     if(timer - mil < 10000){

    }