can't read updated variable

I need to stop/resume the rotation of a fan when a certain key is pressed, so I wrote this C# code:

    public bool rotationFlag = false;
    private float rotationAngle = 2.0f;

    void Update(){
    if (Input.GetKey("right"))
            roationAngle+=1;
        
    if (Input.GetKey("left"))
            roationAngle-=1;
        
    if (Input.GetKeyDown("Keypad0"))
            commuteFan();

    if(rotationFlag){
                fan.transform.Rotate(Vector3.up, rotationAngle);
            }
    }
    
    public void commuteFan(){
            rotationFlag = !rotationFlag;
            }

cummuteFan() method is called when I press the button.

the variable starts on false and the fan correctly doesn’t ratate, when I hit the button, the method is called, the variable values changes and the starts to rotate, but if I want to stop it, it doesn’t work anymore. debug tells me that the value is correctly changed to false in commuteFan() but update() continues to read the old value (true) and the fan doesn’t stop…

any suggestion

if (Input.GetKeyDown(KeyCode.Keypad0))

Use the KeyCode enum to define what keys you want for your input instead of trying to define them by name and see if that works instead.

[SOLVED] I don’t know why, but I created a class with only the bool along with getter/setter methods in it and it works know