Using the pulseIn function

Basically I want to have a button with 2 functions. If it is pressed for less than two seconds, do action A. If it is pressed for more than two seconds, do action B. I have this code but it doesn't seem to work :confused:

int button = 7;
int buttonState = 0;
int lastButtonState = LOW;
long previousMillis = 0;
long interval = 100;
unsigned long duration;

void setup() {
  pinMode (7, INPUT);
}

void loop() {
  buttonState = digitalRead (button);
  unsigned long currentMillis = millis();
  
  if (buttonState == LOW) {
    lastbuttonState = LOW;
  }

if (buttonState == HIGH) && (lastButtonState == LOW) && (currentMillis - previousMillis > interval)) {
    duration = pulseIn (7, HIGH);
    if (duration < 2000000) {

      "do action A"      

      lastButtonState = HIGH;
      previousMillis = currentMillis;
    }

    if (duration > 2000000) {

      "do action B"

      lastButtonState = HIGH;
      previousMillis = currentMillis;
    }
  }
}

what am I doing wrong?

Note the time at which the button state changed.
Note the time at which the button state changed back.
Subtract the readings.
No need for "pulseIn"

forgive, I'm quite new to this. How would I note the time?

Just like you did here: unsigned long currentMillis = millis();