How to escape while control structure with implement of switch case

CrossRoads:
Ah - in that case, when you get a valid key, save it & do the continuous switching on that.

Something like:

void loop()

{
  char key = kpd.getKey();
  if(key)  // Check for a valid key.
  { new_key  = key;}

switch (new_key)
    {

[code]
and make the }s match up at the end again.


[/code]

something like this right? but not working also..

void loop()
{
  char key = kpd.getKey();
  char new_key;
  if(key)  // Check for a valid key.
  {
    {new_key  = key;}
    switch (new_key)
    {
      case '1':
        while(key == '1'){    // while key 1 is pressed, it will keep repeatedly display number 1.
        Serial.println("1");
        key = 'Z';  // or some invalid character
        }
        break;    // supposed that break the case 1 if other case is being pressed