How can i did this OLED menu

switch (key)
{
case 3:
do
{
oled.clear();
oled.drawstring(7, 4, "MENU ONE");
oled.display();
}
while(key==0);
break;
case 2:
do
{
oled.clear();
oled.drawstring(7, 4, "MENU TWO");
oled.display();
}
while(key==0);
break;
case 1:
do
{
oled.clear();
oled.drawstring(7, 4, "MENU THREE");
oled.display();
}
while(key==0);
break;
}

But when i press the key 3 2 1 the oled only show one times of "MENU ONE/TWO/THREE" and not when i press the key 0 back to index

where do yo uassign your new value to key ?

if you are in a switch statement, your value of key is fixed as one, two or three.
it won't change itself if you do not check something to assign a new value to key

and it's best to make a default case in switch statements, just to not get strange results if key has another value

this is my void keyRead();

void keyRead()
{
k0 = analogRead(A0);
k1 = analogRead(A1);
k2 = analogRead(A2);
k3 = analogRead(A3);
key=4;
if(k0>500)
{
key=0;
};
if(k1>500)
{
key=1;
};
if(k2>500)
{
key=2;
};
if(k3>500)
{
key=3;
};
}

the new code:

keyRead();
switch (key)
{
case 3:
do
{
oled.clear();
oled.drawstring(7, 4, "MENU ONE");
oled.display();
}
while(key==0);
break;
case 2:
do
{
oled.clear();
oled.drawstring(7, 4, "MENU TWO");
oled.display();
}
while(key==0);
break;
case 1:
do
{
oled.clear();
oled.drawstring(7, 4, "MENU THREE");
oled.display();
}
while(key==0);
break;
default:
oled.clear();
oled.drawstring(45, 0, day);
oled.drawstring(7, 1, buf);
oled.drawbitmap(3, 16, pic, 128, 48, 1);
if(time>=15)
{
oled.clear();
oled.clear_display();
oled.display();
}
else
{
oled.display();
}
}
}

But when i Release the key one/two/three will back to {default:}

Steen:
where do yo uassign your new value to key ?

if you are in a switch statement, your value of key is fixed as one, two or three.
it won't change itself if you do not check something to assign a new value to key

and it's best to make a default case in switch statements, just to not get strange results if key has another value

Please just cut and paste the code from the IDE between tags - don't use quote tags, and don't use the format for forum option, please

AWOL:
Please just cut and paste the code from the IDE between tags - don't use quote tags, and don't use the format for forum option, please

sorry...This is my first time in this forum...And my native language isn't English i have to use Google Translate... =(