Motor Shield and using a pushbutton to control direction

Hi Everyone, Is there a good reason why my motor sketch is ignoring the push button state? I have a pushbutton as input and when i press it nothing different happens. The motor spins upon startup. I’m trying to get the motor to spin in opposite direction when the push button is pressed.

/******************************
Motor Shield Stepper Demo

For more information see:
https://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/
 
********************************/
//1000's of sec delay
int delaylength = 3;  

// set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
int buttonState = 0;         // variable for reading the pushbutton status

void setup()
{
  //establish motor direction toggle pins
  pinMode(12, OUTPUT); //CH A 
  pinMode(13, OUTPUT); //CH B

  //establish motor brake pins
  pinMode(9, OUTPUT); //brake (disable) CH A
  pinMode(8, OUTPUT); //brake (disable) CH B

  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}

void loop()
{

  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH)
  {
  // turn motor clockwise:
  digitalWrite(9, LOW);
  digitalWrite(8, HIGH);

  digitalWrite(12, HIGH);
  analogWrite(3, 255);

  delay(delaylength);

  digitalWrite(9, HIGH);
  digitalWrite(8, LOW);

  digitalWrite(13, LOW);
  analogWrite(11, 255);

  delay(delaylength);
  
  digitalWrite(9, LOW);
  digitalWrite(8, HIGH);

  digitalWrite(12, LOW);
  analogWrite(3, 255);
  
  delay(delaylength);

  digitalWrite(9, HIGH);
  digitalWrite(8, LOW);

  digitalWrite(13, HIGH);
  analogWrite(11, 255);
  
  delay(delaylength);
  } 
  else
  {
    // turn motor counter-clockwise:
    digitalWrite(9, LOW);
    digitalWrite(8, HIGH);

    digitalWrite(12, HIGH);
    analogWrite(3, 255);

    delay(delaylength);

    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);

    digitalWrite(13, HIGH);
    analogWrite(11, 255);

    delay(delaylength);

    digitalWrite(9, LOW);
    digitalWrite(8, HIGH);

    digitalWrite(12, LOW);
    analogWrite(3, 255);

    delay(delaylength);

    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);

    digitalWrite(13, LOW);
    analogWrite(11, 255);

    delay(delaylength);
  }  
}

Isolate the problem.

Use the "button" example that comes with the Arduino software and make sure that you can read the button.

Then test the motor shield to make sure that you can make the motor spin in both directions.