I need help in keeping a state of a variable

If you want one thing to happen for each button press (or release) look into the state change detection method.

Nowhere in that code do you read a switch. There is a tasteri() function, but it is never called.

More descriptive variable names and some comments would help us to understand what you are trying to do.

Good job on properly posting code. Few seem to bather to read the guidelines. Thanks.