Opening and Closing Door with the Same Key

Hello There;
I have a Door i want to open and close the door using the same input key.
this is my code:

var DoorStatus = false;
var Door:Transform;
var area: int=2;
function Update ()
{
	var forward = (Door.transform.TransformDirection (Vector3.forward));
	//target = GameObject.FindWithTag("Cube").transform;
	if(Physics.Raycast(Door.transform.position, forward,area))
	{
	print("I am infront of the Door");	
	if (Input.GetKey ("e")  !DoorStatus)
		{
			animation.CrossFade("O");
			print ("Door is Open Now");
			DoorStatus = true;
		}

	if (Input.GetKey ("e")  DoorStatus)
		{
			animation.CrossFade("C");
			print ("Door is Closed Now");
			DoorStatus = false;
		}
	}
}

i know where is the problem, it is DoorStatus variable, since it become true in the first if statement and it goes to the second if statement to do it.
how i can fix this

if (Input.GetKey ("e")  !DoorStatus) 
      { 
         animation.CrossFade("O"); 
         print ("Door is Open Now"); 
         DoorStatus = true; 
      } 

      else
      { 
         animation.CrossFade("C"); 
         print ("Door is Closed Now"); 
         DoorStatus = false; 
      }

Perhaps?

CorruptedHeart, I like your code but your “else” statement will also get triggered if the player doesn’t press “e”. I think this will do it:

if (Input.GetKey ("e")) {
    if (!DoorStatus) { 
         animation.CrossFade("O"); 
         print ("Door is Open Now"); 
         DoorStatus = true; 
    } else {
        animation.CrossFade("C"); 
         print ("Door is Closed Now"); 
         DoorStatus = false; 
    }
}

Ah yes, my bad. Close enough though…

Thank you very very much.
it is now working perfectly