How to change boolean state with a push button

I'm just wondering is there any easy or fast way to do this without a new bool variable (state) like I did? I want to change the state of boolean with a push button. Here is the code:

bool state;
bool cd = false;

void setup() {
  // put your setup code here, to run once:
  pinMode(8, INPUT_PULLUP);

}

void loop() {
  // put your main code here, to run repeatedly:
  if(digitalRead(8)==LOW && state==0){
    state=1;
    tnow = millis();
    if((tnow-tlast)>=50){
      tlast=tnow;
      cd ^= true;
    }
  }
  else if(digitalRead(8)==HIGH)
    state=0;
}

the idea was when I push the button and the logic is low, it changes the state of the cd.

But, I only want to change the state one time in one push, so I check if the previous state of the button is low, it changes the state of the cd, and when the previous state of the button is high, it doesn't do anything.

Thank you

I don't understand. It seems to me that you want to change the state of a boolean variable without having a boolean variable.

crashl:
I'm just wondering is there any easy or fast way to do this without a new bool variable (state) like I did? I want to change the state of boolean with a push button. Here is the code:

bool state;

bool cd = false;

void setup() {
 // put your setup code here, to run once:
 pinMode(8, INPUT_PULLUP);

}

void loop() {
 // put your main code here, to run repeatedly:
 if(digitalRead(8)==LOW && state==0){
   state=1;
   tnow = millis();
   if((tnow-tlast)>=50){
     tlast=tnow;
     cd ^= true;
   }
 }
 else if(digitalRead(8)==HIGH)
   state=0;
}




the idea was when I push the button and the logic is low, it changes the state of the cd.

But, I only want to change the state one time in one push, so I check if the previous state of the button is low, it changes the state of the cd, and when the previous state of the button is high, it doesn't do anything. 

Thank you

Just put EXACTLY what you wrote into code:

IF your bool is false, do the button read, and if you get a low, change the bool to true.

Then you will never read the button and the bool will always be true and your written requirement will be fulfilled.

Paul