# Help with jumping script

**URL:** <https://forum.kirupa.com/t/help-with-jumping-script/41608>\
**Category:** programming\
**Created:** [January 31, 2004, 1:52am UTC](https://forum.kirupa.com/t/help-with-jumping-script/41608 "2004-01-31T01:52:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fydus](https://avatars.discourse-cdn.com/v4/letter/f/8c91f0/32.png) [@Fydus](https://forum.kirupa.com/u/Fydus)\
**Post date:** [January 31, 2004, 1:52am UTC](https://forum.kirupa.com/t/help-with-jumping-script/41608/1 "2004-01-31T01:52:55Z")

</div>

Im trying to make a mario type game and can’t seem to get the jumping to work the way I want. I want the character to jump of course, but I want the jump to be key sensitive. I want the character to jump higher when the button is held longer. The code I have works, until you press the key twice while the character is in mid jump. The character will fall down further then what it should fall. I know the problem is with my countHeight variable which adds to the height of the jump when the key is held down. Can anybody help me come up with a better script that is fool proof?

onClipEvent(load)  
{  
var count = 0;  
var countHeight = 0;  
var jump = false;  
var jumpLevel = 2;  
var jumpY = -9;  
}

onClipEvent(enterFrame)  
{  
if(key.isDown(Key.CONTROL))  
{  
if(countHeight != 9)  
countHeight ++;  
if(jump != true)  
jump = true;  
}

```
            if(jump)
            {
                count ++;
            	this._y += jumpY;
            	if(count == jumpLevel+countHeight)
                {
	                jumpY = -jumpY;
            	}
                if(count == 2*(jumpLevel+countHeight))
            	{
                	jumpY = -jumpY;
            		count = 0;
                	jump = false;
            	}
            }
            else
                countHeight = 0;

```

}
