Moving also when jumping

I took the character controller script from the documentations and made it a side scroller.
i want to move also when i jump, but when i do that (move the “isGrounded” to where the jumping is, the players gravity is screwed up…
the Character controller script

 var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;

private var moveDirection : Vector3 = Vector3.zero;

function Update() {
    var controller : CharacterController = GetComponent(CharacterController);
    if (controller.isGrounded) {
        // We are grounded, so recalculate
        // move direction directly from axes
        moveDirection = Vector3(Input.GetAxis("Horizontal"), 0, 0);
        moveDirection = transform.TransformDirection(moveDirection);
        moveDirection *= speed;
        
        if (Input.GetButton ("Jump")) {
            moveDirection.y = jumpSpeed;
        }
    }

    // Apply gravity
    moveDirection.y -= gravity * Time.deltaTime;
    
    // Move the controller
    controller.Move(moveDirection * Time.deltaTime);
}

Store your vertical movement separately. The code you currently have resets it to zero every frame (movedirection = Vector3(blah)). The way I did it is:

private var localGravity : float = 0.0;

function Update () {
    var controller : CharacterController = GetComponent(CharacterController);
    // move direction directly from axes
    moveDirection = Vector3(Input.GetAxis("Horizontal"), localGravity, 0.0);
    moveDirection = transform.TransformDirection(moveDirection);
    moveDirection *= speed;
        
    if (controller.isGrounded) {
        localGravity = 0.0;
        if (Input.GetButton ("Jump")) {
           localGravity = jumpSpeed;
        }
    }

    // Apply gravity
    localGravity -= gravity * Time.deltaTime;
    
    // Move the controller
    controller.Move(moveDirection * Time.deltaTime);

Works thank you