Delay in Interrupt or Code Design Error?

My latest problem is pretty simple.
I want to press a button,then the program will stall and go in interrupt mode where it executes the following code:

void eepw(){
  buttonValue = analogRead(A4);
  if (buttonValue >= 450 && buttonValue <= 505) { 
    Serial.println(analogRead(A4)); //debug
       Serial.println(EEPROM.read(0)); //debug
    if(EEPROM.read(0)== 0){
  EEPROM.write(0, 1);
delay(1000);   //error
    }
  else
  {EEPROM.write(0,0);

  }
     Serial.println(EEPROM.read(0)); //debug
     delay(1000); //error
}
}

it's pretty simple,but my main issue that i experience is that while i press the button (let's say around 200 ms) it keeps changing the value in eeprom address.(Like it goes,0 then 1 then 0 etc,until i leave the button where it just stop in the last value it had).
I have read 2 or 3 posts where everyone advices not to use interrupts in ISR and i can see the why,as in my code in order for the delay to work needs to be over 10000.I'm looking for alternative way to just be single time independent of the press time in the button.In ISR state the loop() is irrelevant so i can't use delay() in loop()

There right... Don’t delay and don’t do serial operations in an ISR.

The reason why you are doing this is as a sticking plaster to some other problem. Presumably because your mainline code is using blocking functions (delay and loops), and so you cannot test for a button press reliably there.

If you could, then executing the code you gave (without performing any other processing) would be easy.

Edit: So to answer your post title (although probably not in the way you want) Code design error (in your main program).

pcbbc:
There right... Don’t delay and don’t do serial operations in an ISR.

The reason why you are doing this is as a sticking plaster to some other problem. Presumably because your mainline code is using blocking functions (delay and loops), and so you cannot test for a button press reliably there.

If you could, then executing the code you gave (without performing any other processing) would be easy.

Edit: So to answer your post title (although probably not in the way you want) Code design error (in your main program).

The //debug comments can be omitted.The functions main purpose is to change a value in eeprom based on click.It could be standalone but must be called only when the signal in a4 changes.The issue arrives when the button stays pressed for "long" time.I need one change per click let's say.

.The issue arrives when the button stays pressed for "long" time.I need one change per click let's say.

The state change detection method may help with that.

groundFungus:
The state change detection method may help with that.

If i get what it says,it is working like a "pin state detector"and just counts the highs and lows.Shouldn't the 3rd parameter in attachInterrupt(digitalPinToInterrupt(pin), ISR, >>>>mode<<<<) do that?But even with specified state (HIGH) or CHANGE,the issue persist.
As you can see in this log:
22:59:09.733 -> 479
22:59:09.733 -> 1
22:59:09.767 -> 0
22:59:09.767 -> 479
22:59:09.767 -> 0
22:59:09.767 -> 1
22:59:09.767 -> 479
22:59:09.767 -> 1
22:59:09.801 -> 0
22:59:09.801 -> 479
22:59:09.801 -> 0
22:59:09.801 -> 1
22:59:09.801 -> 479
22:59:09.836 -> 1
22:59:09.836 -> 0
22:59:09.836 -> 479
22:59:09.836 -> 0
22:59:09.836 -> 1
22:59:09.836 -> 479
22:59:09.836 -> 1
22:59:09.871 -> 0
22:59:09.871 -> 479
22:59:09.871 -> 0
22:59:09.871 -> 1
22:59:09.871 -> 479
22:59:09.871 -> 1
22:59:09.871 -> 0
22:59:09.906 -> 479
22:59:09.906 -> 0
22:59:09.906 -> 1
22:59:09.906 -> 479
22:59:09.906 -> 1
22:59:09.906 -> 0
22:59:09.906 -> 479
22:59:09.906 -> 0
22:59:09.906 -> 1
22:59:09.906 -> 479
22:59:09.941 -> 1
22:59:09.941 -> 0
The first no. is the analog input,second no. is initial value in address,third no is new value in address.This is in a simple click of around 200 ms.

The point of the state change detection is to sense when the switch becomes closed or open not when the switch is closed or open.

Try the state change code as written in the example. Press the switch and hold it. Does the count increase as long as the switch is held or does the count increase by only one?

And like pcbbc said, sensing the state if a human actuated switch is not a good use of an interrupt. If you would post all of your code and describe what you want it to do, we may be able to help you write the code so that an interrupt is not required.

 buttonValue = analogRead(A4);

Why analogRead() for a switch?

groundFungus:
The point of the state change detection is to sense when the switch becomes closed or open not when the switch is closed or open.

Try the state change code as written in the example. Press the switch and hold it. Does the count increase as long as the switch is held or does the count increase by only one?

And like pcbbc said, sensing the state if a human actuated switch is not a good use of an interrupt. If you would post all of your code and describe what you want it to do, we may be able to help you write the code so that an interrupt is not required.

 buttonValue = analogRead(A4);

Why analogRead() for a switch?

Later today i will post a more complete code.Some clarification though because it seems that my code is not clear.

The button in my code has 2 functions.Firstly it works as a Interupt signal in D2 pin,after the signal has been sent and know ISR is enabled,Then buttonValue = analogRead(A4) goes to A4 pin (while beeing inside the ISR) and reads the button analog signal.Based on the value it should change the value in 0add of EEPROM.The value should be 0 OR 1,not addition.

My issue comes down to,while my code can see that the button has been pressed initialy,it doesn't understand that a human press should be around 200ms,and for 200ms just do changes in 0add.