How to make a character jump in unity 2d?

I was trying to make a character jump but the code I came up with the character keeps on going up as long as you are pressing the button so is there a way to make it as any normal jump in a normal game?

here is my code:

if (controller.moving.y > 0) {
        if(absVelY < maxVelocity.y)
            forceY = jetSpeed * controller.moving.y;

and this is the moving function from the controller:

moving.x = moving.y = 0;

    if (Input.GetKey ("right")) {
        moving.x = 1;
    } else if (Input.GetKey ("left")) {
        moving.x = -1;

    if (Input.GetKey ("up")) {
        moving.y = 1;
    } else if (Input.GetKey ("down")) {
        moving.y = -1;

You are going to need a boolean check, to see if player isGrounded. If he is not grounded that means he is in the air. If he is in the air then he cannot jump.