Stepper motor won't change directions!
You work with accelleration and absolute positions. Are you aware of that?
This Library is not made for running permanently in the same direction. It let you define a position where the movement should end, an acceleration or speed and the controller moves the motor to that position.
The run method must be called permanently, It triggers the steps. So, I put it directly into the loop() method.
The following prog should hopefully move the motor towards position 1000 if you press the 8-button, towards position -1000 if you press the 9-button and stops if both buttons are off. I have not the hardware available at the moment, you it's just blind programming. Use it as an idea.
#include &lt;AccelStepper.h&gt;
AccelStepper stepperX(1, 3, 2);

void setup() 
{
  pinMode(8, INPUT)
  pinMode(9, INPUT);

  stepperX.setMaxSpeed(100.0);
  stepperX.setAcceleration(3.0);
}

int positivePosition = 1000;
int negativePosition = -1000;

void loop() 
{
  if ( digitalRead(8) == HIGH ) 
  { 
    stepperX.moveTo(positivePosition);
  }
  else if (digitalRead(9) == HIGH) 
  {
    stepperX.moveTo(negativePosition);
  }
  else
  {
    stepperX.stop();
  }
  stepperX.run();
}