Adding Tone to menu buttons, having problems

Started out with a simple task of adding a “Beep” for each button press on a keypad to be used with LCD menu.

Note that the Menu is not complete in this code, but working.

void  readButtons(){  //read buttons status

Does what it says it checks the status of four buttons Esc., Up, Down and Enter. When the menu is displaying the default page “Main Menu” the Up and Down button works fine (does nothing but beep) but the Esc. one does not sound correct. It sounds like it is getting cut off and starting over on every press.

I have changed the debounceDelay time and tone duration, but they don’t appear to have any change on the behavior.
The problem appears to be caused by the menu code.

This is what I added to make the beep on each key press.

 if (buttonEnterState==HIGH || buttonEscState==HIGH ||  buttonLeftState==HIGH || buttonRightState==HIGH){
     tone(5, 1050, 200); 

The full code is attached.

menu.ino (12.9 KB)

Menu file…

MenuBackend.h (6.38 KB)