# How can I shorten this if statement?

**URL:** <https://forums.unrealengine.com/t/how-can-i-shorten-this-if-statement/458698>\
**Category:** Blueprint\
**Tags:** key, string, unreal-engine, Blueprint, question\
**Created:** [November 22, 2019, 4:44am UTC](https://forums.unrealengine.com/t/how-can-i-shorten-this-if-statement/458698 "2019-11-22T04:44:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Redageddon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Redageddon](https://forums.unrealengine.com/u/Redageddon)\
**Post date:** [November 22, 2019, 4:44am UTC](https://forums.unrealengine.com/t/how-can-i-shorten-this-if-statement/458698/1 "2019-11-22T04:44:05Z")

</div>

Is there any way i can shorten this?

 ![292820-help.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/a/6/3a612272d5706da8731040c2382f0c02be90c798.png)

also the normal

![292821-ex.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/f/1/0f1cd0feb976d283b832cc67920bddc78c3d7d16.png)

doesnt work.  
Pretty much what i’m trying to do here is convert key press into a string. Does anyone have any ideas as to how i could shorten this?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_19f830cf1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_19f830cf1](https://forums.unrealengine.com/u/anonymous_user_19f830cf1)\
**Post date:** [November 22, 2019, 8:45am UTC](https://forums.unrealengine.com/t/how-can-i-shorten-this-if-statement/458698/2 "2019-11-22T08:45:44Z")

</div>

What you can just do is one of these options:

1. Inputaction | KEY  
With this you will need to create some inputactions in the Project Settings.Make them, spawn the node in the BP editor and set the value corresponding the key.

2. Use the method that is “not working”

Now this si basically the same but instead of using input modes you use these keys. Then “OnPressed” will need to set the value, or break down the key. Make sure you are posessing the pAYER CHARACTER

---

<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:** [November 22, 2019, 10:28am UTC](https://forums.unrealengine.com/t/how-can-i-shorten-this-if-statement/458698/3 "2019-11-22T10:28:16Z")

</div>

You can skip the switch if you do not care about a key-specific action:

 ![292831-annotation-2019-11-22-102738.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/e/4/2e4abef38ac3186379d7d7ac53ad391038a67dad.png)

or this:

 ![292832-annotation-2019-11-22-103302.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/0/6/906b2df953608e16510ba903ca2f1dd542862487.png)

Many other ways, too, depending on what the end result is supposed to be used for.

---

<div class="post-metadata">

**Author:** ![Redageddon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Redageddon](https://forums.unrealengine.com/u/Redageddon)\
**Post date:** [November 22, 2019, 8:20pm UTC](https://forums.unrealengine.com/t/how-can-i-shorten-this-if-statement/458698/4 "2019-11-22T20:20:13Z")

</div>

any key isnt working

---

<div class="post-metadata">

**Author:** ![Redageddon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Redageddon](https://forums.unrealengine.com/u/Redageddon)\
**Post date:** [November 22, 2019, 8:35pm UTC](https://forums.unrealengine.com/t/how-can-i-shorten-this-if-statement/458698/5 "2019-11-22T20:35:13Z")

</div>

nvm i retardo
