Flying object does not stop

Hi Iam using the following code for flying object as 1st person controller. once i click a button on keyboard, it continues to move without stopping, what am i not doing right? any help is appreciated.

what i want is: with a button click,i just wnat it to move 5 units or so and stop. not just continue to move constantly.

function FixedUpdate() {
// Calculate the move direction
moveDirection = new Vector3(Input.GetAxis(“Horizontal”), 0, Input.GetAxis(“Vertical”));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
// Move the controller
var controller : CharacterController = GetComponent(CharacterController); controller.Move(moveDirection * Time.deltaTime);}

You need to change your speed .

While the key is pressed , then the speed should be a predefined value.
When the key stopped being pressed, change the speed to 0 or even better add gravity by applying gravitational pull on an update function.

So basically an update function that alters speed looks like this :

function Update()
    if (Input.GetKeyDown(
        speed = 10.0 ;
        speed = speed - 9.85 * Time.deltaTime;