Concerning your current code the following snip-it, occurring twice, does nothing
unsigned long currentMillis = millis();
if ( (currentMillis - previousMillis) > interval )
{
previousMillis = currentMillis;
}
If a multiple association condition test succeeds then you may safely use 'else' to exclude additional tests.
if ( keyPressed == 1 )
{
...
}
else if ( keyPressed == 2 )
{
...
if ( key == '#' )
{
...
}
else if ( key == '*' )
{
...
}
...
}