Shift register to fade LED's on and keep them on until input

Ok so the loop break out is the following,

if (justpressed[0]==2){

Break;

}

I need the button to able be pressed at anytime during the loop. Which then jumps to the second if, but if the button is pressed three times it sets the value back to 0 hence starting the cycle again.

Can you simplify the code for a double press, I have re-engineered that code from one that I use to control buttons on a wave shield.

Thanks for your help mike :slight_smile: