# How do I get keyboard events in user widget?

**URL:** <https://forums.unrealengine.com/t/how-do-i-get-keyboard-events-in-user-widget/480892>\
**Category:** UI\
**Tags:** Input, mapping, unreal-engine, keyboard, question, UMG\
**Created:** [March 26, 2021, 2:21am UTC](https://forums.unrealengine.com/t/how-do-i-get-keyboard-events-in-user-widget/480892 "2021-03-26T02:21:37Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![GamerAwesome949](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GamerAwesome949](https://forums.unrealengine.com/u/GamerAwesome949)\
**Post date:** [March 26, 2021, 2:21am UTC](https://forums.unrealengine.com/t/how-do-i-get-keyboard-events-in-user-widget/480892/1 "2021-03-26T02:21:37Z")

</div>

I am setting up an input remapping menu, and I am having trouble getting it to listen for a key. Right now I have it set to change a “ListeningFor” variable to “Jump”, wait 4 seconds, then change it back to “None” when the “JumpRemap” button is clicked. My thinking is, I have OnAnyKey, then unless “ListeningFor” is equal to “None”, then whatever “ListeningFor” is, set that input action to the key that was pressed. However, I can’t figure out any way to have input recognition like that. Thanks in advance!

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [March 26, 2021, 8:42am UTC](https://forums.unrealengine.com/t/how-do-i-get-keyboard-events-in-user-widget/480892/2 "2021-03-26T08:42:37Z")

</div>

Have you tried the input key selector, this is what it’s for:

![333605-screenshot-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/7/3/773a05eff1614621993a75c190f96206a3c265e0.jpeg)

---

<div class="post-metadata">

**Author:** ![GamerAwesome949](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GamerAwesome949](https://forums.unrealengine.com/u/GamerAwesome949)\
**Post date:** [March 29, 2021, 8:52pm UTC](https://forums.unrealengine.com/t/how-do-i-get-keyboard-events-in-user-widget/480892/3 "2021-03-29T20:52:31Z")

</div>

Oh, I didn’t think of that! Thank you!

---

<div class="post-metadata">

**Author:** ![GamerAwesome949](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GamerAwesome949](https://forums.unrealengine.com/u/GamerAwesome949)\
**Post date:** [March 29, 2021, 10:06pm UTC](https://forums.unrealengine.com/t/how-do-i-get-keyboard-events-in-user-widget/480892/4 "2021-03-29T22:06:20Z")

</div>

How do I tell it which InputAction to map?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [March 30, 2021, 7:40am UTC](https://forums.unrealengine.com/t/how-do-i-get-keyboard-events-in-user-widget/480892/5 "2021-03-30T07:40:15Z")

</div>

This node only give you the key, you then need to apply it with

![334095-screenshot-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/8/6/886658ef4c3caed568bf84fc0bce2ccfc0daca49.jpeg)

Try:

---

<div class="post-metadata">

**Author:** ![GamerAwesome949](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GamerAwesome949](https://forums.unrealengine.com/u/GamerAwesome949)\
**Post date:** [March 30, 2021, 2:14pm UTC](https://forums.unrealengine.com/t/how-do-i-get-keyboard-events-in-user-widget/480892/6 "2021-03-30T14:14:31Z")

</div>

Okay, I am very new to all of this and have no earthly idea what BreakInputChord is, but I will copy what you have. Thanks!

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [March 30, 2021, 2:23pm UTC](https://forums.unrealengine.com/t/how-do-i-get-keyboard-events-in-user-widget/480892/7 "2021-03-30T14:23:54Z")

</div>

As you can see, it breaks the input key down into which key is was plus which modifier keys were also held at the time.

I think it’s covered in the vid…

---

<div class="post-metadata">

**Author:** ![GamerAwesome949](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GamerAwesome949](https://forums.unrealengine.com/u/GamerAwesome949)\
**Post date:** [March 30, 2021, 4:30pm UTC](https://forums.unrealengine.com/t/how-do-i-get-keyboard-events-in-user-widget/480892/8 "2021-03-30T16:30:27Z")

</div>

How do I tell it to replace the mapping instead of simply adding another one?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [March 30, 2021, 4:34pm UTC](https://forums.unrealengine.com/t/how-do-i-get-keyboard-events-in-user-widget/480892/9 "2021-03-30T16:34:18Z")

</div>

You have to look at what they typed, and see if it has changed.

---

<div class="post-metadata">

**Author:** ![GamerAwesome949](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GamerAwesome949](https://forums.unrealengine.com/u/GamerAwesome949)\
**Post date:** [March 30, 2021, 4:39pm UTC](https://forums.unrealengine.com/t/how-do-i-get-keyboard-events-in-user-widget/480892/10 "2021-03-30T16:39:09Z")

</div>

So I have a bool for wether or not the mapping is different, then presumably a branch, and then what? I don’t know what to do to actually do the removing, because RemoveInputActionMapping requires a key to remove, and GetInputActionMapping by Name puts out an array instead of a mapping, so I cannot simply get it, then remove it, then add another.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [March 30, 2021, 4:54pm UTC](https://forums.unrealengine.com/t/how-do-i-get-keyboard-events-in-user-widget/480892/11 "2021-03-30T16:54:11Z")

</div>

When the player comes into the menu, you have to store the current action key in a variable.

Then when they click the input selector, you have to see if it has changed. If it has, you then clear the current action mapping and put the new one in.

I have it in two macros like this:

 ![334143-screenshot-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/7/1/0711dc1c96ebd087f53ffbf9d91f82879ad08d1b.jpeg)

Inside, they are:

 ![334144-screenshot-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/3/2/c32b2a99bc5b77a97231a3b7f493b091714ad2d1.jpeg)

 ![334145-screenshot-3.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/9/5/3952deaae6fe81eab2aa159cd4a00358e77195b7.jpeg)

---

<div class="post-metadata">

**Author:** ![GamerAwesome949](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GamerAwesome949](https://forums.unrealengine.com/u/GamerAwesome949)\
**Post date:** [March 30, 2021, 5:36pm UTC](https://forums.unrealengine.com/t/how-do-i-get-keyboard-events-in-user-widget/480892/12 "2021-03-30T17:36:27Z")

</div>

Thank you!!

---

<div class="post-metadata">

**Author:** ![GamerAwesome949](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GamerAwesome949](https://forums.unrealengine.com/u/GamerAwesome949)\
**Post date:** [March 31, 2021, 7:43pm UTC](https://forums.unrealengine.com/t/how-do-i-get-keyboard-events-in-user-widget/480892/13 "2021-03-31T19:43:03Z")

</div>

So how do I get to what it was set as previously? I can’t find a node for “GetActionMapping” or anything similar.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [March 31, 2021, 7:56pm UTC](https://forums.unrealengine.com/t/how-do-i-get-keyboard-events-in-user-widget/480892/14 "2021-03-31T19:56:15Z")

</div>

You have to keep it in the save game…

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/5/6/2565d63070f1f1cbb9fe7f1ff872cce4af952f13.jpeg "HTF do I? Use the SaveGame Object in Unreal Engine 4") ](https://www.youtube.com/watch?v=_4usRrTiqak)
