Can Switch Case statements be outside the void loop?

while (keys != '#')keys is an array.
'#' is a single character.
The comparison makes no sense.