How to lock animation from repeating?


I made animation with doors and when I press once e it will play animation and door are open for now. However when I press E again it will repeat action which opens doors. How can I lock E button and unlock it when for example R is pressed which opens doors and other way around ? What I want to achieve is only to stop repeating animation when user press E button again instead of repeating the animation again. Will I need to make IDLE animation ?

That is my code:

function Update () 
    if (Input.GetKeyDown("e"))

Every help is appreciated.

this has been answered multiple times, and can also be answered by looking in the documentation.

I would recommend a flag value. Store a boolean of the door state and then only allow door action if it is true.

public boolean doorsClosed = true;

if (Input.GetKeyDown("e") && doorsClosed)
    // open doors

Also, check out the Stealth Unity tutorial. They do some pretty cool work with double and single doors: Learn game development w/ Unity | Courses & tutorials in game design, VR, AR, & Real-time 3D | Unity Learn.