How do I use sleep mode and wake up with "Long press button"?

Hi! I’m going to use one button to make Arduino turn on/off.
The first button to wake up in sleep mode will work, but pressing the button to use the sleep mode stops working.
I didn’t use interrupt, should I use interrupt?
And The LED works the same in sleep mode. Is there a way to turn off the machine completely without using a relay? There’s not much space on the device I’m trying to create to add relays.
I’d appreciate your advice.

I tried to turn the power on and off like a toggle.

void loop() {
  static boolean LedState = LOW; //static은 정적 변수. 전역 변수처럼 만들어 주는거?
  static unsigned long last;
  int swState = readSw(); //버튼 누른 시간 계산한것을 변수에 저장.

  //LOW, HIGH, RISING, FALLING, CHANGE 중 하나 선택
  //attachInterrupt(0, wakeUp, LOW);  //하드웨어 인터럽트, 0 = 2번핀(인터럽트 0번) LOW신호(버튼 누름)일 때 인터럽트(wake Up함수) 발생.
 
  if (LONG_PRESS == swState) //누른 시간값이 long일 떄
  {   
   if(toggle == LOW)
   {
    wakeUp();
    toggle = !toggle;
   }
   else if(toggle == HIGH)
   {
    Sleep();
    toggle = !toggle;
   }
  }
  //TEST 
  else if (SHORT_PRESS == swState) //누른 시간값이 short일 때
  { 
    Serial.println("SHORT PRESSED");
    digitalWrite(LED, HIGH); 
    delay(100);
    digitalWrite(LED, LOW);
    delay(100);
    digitalWrite(LED, HIGH); 
    delay(100);
    digitalWrite(LED, LOW);
    delay(100);
  }
   //detachInterrupt(0);
}

Function used by this code.

void Sleep()
{
  Serial.println("Sleep mode on...");
  LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); //슬립모드 실행
  delay(500);
}

void wakeUp() //인터럽트
{
  Serial.println("Wake up!!!");
  digitalWrite(LED, HIGH);  
  delay(3000);
  digitalWrite(LED, LOW);  
}

//*********************************************************************************************************************
//버튼 시간을 계산하는 함수, 1초 기준으로 롱프레스,숏프레스 결정
int readSw() //press time
{
  static boolean prev = HIGH;
  static unsigned long last, pressed;
  boolean curr;

  if ((millis()-last) >= 10) //버튼입력처럼 빠르게 상태를 체크해야 하는 경우 delay보다는 millis가 좋음.
  {
    curr = digitalRead(SW); //버튼의 상태값을 변수에 저장. 버튼 눌렀을때 LOW가 됨.
    if ((HIGH==prev)&&(LOW==curr)) //버튼을 눌렀을때
    { 
      pressed = millis(); 
      prev = LOW;
    } 
    else if ((LOW==prev)&&(HIGH==curr)) 
    {
      prev = HIGH;
      if ( (millis()-pressed) > 1000) //1초 기준
      {
        return LONG_PRESS; //1초 보다 길게 누르면 롱프레스
      }      
      else
      {
        return SHORT_PRESS; //1초 보다 짧으면 숏프레스
      }
    }
    last = millis();
  }
  return RELEASED;
}

Thank you!

Your description of what you want to do is not clear.

I don't see how you can use a long press to wake up an Arduino because the Arduino is not able to measure the length of a button press when it is asleep.

You could use a short press (actually just the initial downward movement of the button) to wake the Arduino and use a long press to select SLEEP

If you need more help you need to post the complete program.

...R