# Blueprint, increase float value when pressing on a key

**URL:** <https://forums.unrealengine.com/t/blueprint-increase-float-value-when-pressing-on-a-key/784807>\
**Category:** Blueprint\
**Tags:** key, float, unreal-engine\
**Created:** [March 6, 2023, 11:52am UTC](https://forums.unrealengine.com/t/blueprint-increase-float-value-when-pressing-on-a-key/784807 "2023-03-06T11:52:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matth\_mat](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Matth\_mat](https://forums.unrealengine.com/u/Matth_mat)\
**Post date:** [March 6, 2023, 11:52am UTC](https://forums.unrealengine.com/t/blueprint-increase-float-value-when-pressing-on-a-key/784807/1 "2023-03-06T11:52:10Z")

</div>

Hi, I’m new to the blueprint system and I’m trying to do this simple stuff but I don’t know how to do it.  
Basically I have a float value and what I want is when a press a specific key, this value increase as long as a keep pressing the key and when I release, the value stop increasing.  
I seem pretty simple but I didn’t find a way of doing that

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 6, 2023, 12:07pm UTC](https://forums.unrealengine.com/t/blueprint-increase-float-value-when-pressing-on-a-key/784807/2 "2023-03-06T12:07:44Z")

</div>

Try this:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/6/c/86c19b95292bc9f25ff5f9bae961dfe63af9ce75.png)

---

<div class="post-metadata">

**Author:** ![Matth\_mat](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Matth\_mat](https://forums.unrealengine.com/u/Matth_mat)\
**Post date:** [March 6, 2023, 12:39pm UTC](https://forums.unrealengine.com/t/blueprint-increase-float-value-when-pressing-on-a-key/784807/3 "2023-03-06T12:39:25Z")

</div>

Thanks it work ! and do you know how can I limited the value between a specific range. Like for example, the value is between 5 and 10 and it can’t go bigger than 10 even if you keep pressing the key.

And also is there a may to decrease the value when you press a different key ?

---

<div class="post-metadata">

**Author:** ![Graylord](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Graylord](https://forums.unrealengine.com/u/Graylord)\
**Post date:** [March 6, 2023, 12:47pm UTC](https://forums.unrealengine.com/t/blueprint-increase-float-value-when-pressing-on-a-key/784807/4 "2023-03-06T12:47:49Z")

</div>

You have min and max nodes you can use, or clamp if you want to do both at once.

As for how to subtract instead of adding, not to be a jerk, but I think you’ll figure it out if you spend 20 seconds looking at the blueprint you copied.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 6, 2023, 12:48pm UTC](https://forums.unrealengine.com/t/blueprint-increase-float-value-when-pressing-on-a-key/784807/5 "2023-03-06T12:48:12Z")

</div>

Use a `Clamp` node before setting a value.

> And also is there a may to decrease

Subtract instead of adding.
