Debounce buttons

I have made a code for a foot controlled midi pedal. At first i tried to debounce the buttons with delay, but as you might expect that doesnt work very well. So i tried the change the code with millis() and debouncedelay. But im not sure if i doing it the right way. Below is a piece of the code that i have changed. Is this the way to go?

shiftOn = digitalRead(notes[8]);

	if ( (millis() - lastDebounceTime) > debounceDelay) {
	
  		if (shiftOn == HIGH) && (shiftOn != shiftOnLast){
    			if (mode == 0) {
      			mode = 1;
      			digitalWrite(39, HIGH);
     			lastDebounceTime = millis();
    			}
    			else if (mode == 1) {
      			mode = 0;
      			digitalWrite(39, LOW);
     			lastDebounceTime = millis();
    			}
   		shiftOnLast = shiftOn;
  		}


  	if ((shiftOn == LOW) && (shiftOn != shiftOnLast))  {
		shiftOnLast = shiftOn;
     		lastDebounceTime = millis();
  		}


	}

But im not sure if i doing it the right way.

I am. You are not. There is no switch bouncing if the switch has not changed state. So, that is the FIRST thing you need to test. Then, bouncing MAY be happening is this change is too soon after the previous change. So, time is the SECOND thing you check.

shiftOn = digitalRead(notes[8]);

	if ( (shiftOn != shiftOnLast) && (millis() - lastDebounceTime) > debounceDelay)) {
	
  		if (shiftOn == HIGH){
    			if (mode == 0) {
      			mode = 1;
      			digitalWrite(39, HIGH);
    			}
    			else if (mode == 1) {
      			mode = 0;
      			digitalWrite(39, LOW);
    			}
   		shiftOnLast = shiftOn;
    		lastDebounceTime = millis();
  		}


  		if (shiftOn == LOW){
		shiftOnLast = shiftOn;
     		lastDebounceTime = millis();
  		}


	}

You mean like this??

You mean like this??

No. There is no reason to use a compound if statement when nested if statements are easier to understand and debug.