Its actually pretty easy i just check if the player is on the floor and if he pressed space and then i add some upwards velocity. and every frame i subtract some speed so it goes down -> gravity. and i reset the vertical vel when im on the floor. hope i could help you.