I was dealing with that problem but I fixed with this, check it out:
When Z key was pressed and Player is on ground, set a GravityTimer to 10
If GravityTimer > 0, Substract 1 from GravityTimer
If GravityTimer = 0, set vertical speed to 0
If Z key is released, set vertical speed to 0.
That way, if you keep the button pressed, you will jump the same height you wanted, but if you release the button, the player will stop.
Just play with that values (GravityTimer and that stuff) and you'll get what you want, or atleast I did.
Good luck!