Why won't this code break?

Hi, fairly new to the world of coding and Arduino.

Have been messing around with this piece of code for hours and cannot figure out why it wont break when # is pressed on the keypad.

if(key == 'B'){
  keyB = true;
  
  while(keyB=true){
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Power generated:");
  lcd.print(power2);
  lcd.setCursor(0,1);
  lcd.print("Power needed:");
  lcd.print(load);
  delay(2000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Power used:");
  lcd.setCursor(0,1);
  lcd.print("Power deficit:");
  delay(2000);
  
  if(key == '#'){
    keyB=false;
    break;
    }
  }
}

Its probably something simple, but I cannot pick it. Any help would be appreciated.
Cheers

The test for # is inside the if that already established that key is 'B'. Key isn't read again in the while loop, hence the symptom you see.

Ah, thanks a lot!

  while(keyB=true){

= != ==