K, I remember having a similar issue when I did a keypad program
so instead of changing to int
I did Case statements
switch(key)
case'0'
case'1'
case'2'
case'3'
I know this is probably not the easiest way, but I remember it being a problem. but with this way you can use the * and # keys or choose to ignore them
the other command I think worked was
int buttonkey = 0;
buttonkey = key.toInt();
Serial.print(buttonkey);