Actor behavior depending on how long key is pressed

Hello everyone, this is my first post here at gamesalad so dont be mean, 
I am currently making a platform game were I want my player to have different acceleration in his jump depending on how long you press the key, is this possible? I have already tried with the timer but could not get it to work. Has someone done this in your own games an if that is the case how did you do it?
Thanks for reading! (My English is not so good, I am from Sweden)

I am currently making a platform game were I want my player to have different acceleration in his jump depending on how long you press the key, is this possible? I have already tried with the timer but could not get it to work. Has someone done this in your own games an if that is the case how did you do it?
Thanks for reading! (My English is not so good, I am from Sweden)
Comments
I am new to GS as well but I know you can do this. Take a look a the "Cannon" game under the New project tab, when you launch GS. You will see that the longer you hold down on the cannon the more power you get. You will also see a power bar to the side the shows you your power level.
Also, I have posted a similar question called "Drag power." I have a cannon shooter game and I want to be able to tap and drag away from the cannon in order to control the power and direction of the shot. In your case, you could tap and drag in the direction of your jump and control how strong the jump will be.
The people in the forum are VERY helpful!
-Dooki
Edit. You want a rule that when touch pressed change a game attribute interger to 1 and do an otherwise when released change to 0. Then on actor when game attribute is 1 then accelerate and when 0 do nothing
I know that acceleration is a build up, but when I use the acceleration to jump as in the platformer example in GS you cant hold down the jump-key for a longer time to have a bigger jump. I still do not really get how you should do in order to be able to charge a jump, there must be someone else who have done this before?
You could try something like this:
Create a global Boolean attribute called TouchPressed
Create a global real attribute called "AccelerationBoost"
Whatever actor is controlling the touch to move your player, create this rule
When Touch is pressed
Change attribute TouchPressed = True
Otherwise TouchPressed = false
Timer
Every 0.1 Seconds
Change Attribute AccelerationBoost to AccelerationBoost + 0.1
(This rule make it so when touch is pressed, AccelerationBoost will increase uniformly by 0.1 every 0.1 seconds)
In your player actor make this rule
When TouchPressed = True
Change Velocity
Speed = Game.AccelerationBoost
Direction = (whatever direciton settings you have)
So basically your player's speed will increase the longer you hold down the touch.
Let me know if this works.