How to set UMG buttons to keys?

Is there a way to assign a button to a input keyboard key? like a joystick in a touch interface setup.

I just saw your question and had been sorta wondering that myself so I messed around a bit. Turns out you can create the input event in your player BP, have it set a variable, cast to the player BP from the widget event graph, and do your thing from there using the variable you’re gathering.

For whatever reason, I was unable to just cast to the player BP and get the input event itself, so…

You’ll have to use Event Tick in the widget event graph, but to maximize processing efficiency, you can do something like have a branch right after it that checks if the button(s) that would be affected are even visible, or whatever condition applies to your scenario. THEN you have it cast to the player BP (or whatever BP you wanna use) and use a branch to see if the variable you have is true or false. This way, you are not perpetually casting to the BP unless it is appropriate to do so. But if this is a button that is always visible, you’ll just have to deal with it (unless there is a better way!).

For example, you can setup your variable in the BP to activate on button press and deactivate on button release, so you won’t be dealing with a variable that is always ‘on.’

Play around with that and see if does what you need. Lemme know!

Hi sonike,

I was also having a few issues thinking on how to do this, but the best way I came up with working on it was to set up custom events on your UMG Blueprint to perform certain actions, and then in your Player Controller/Character Controller/Level Blueprint, you can CAST to the UMG Blueprint that you’ve got loaded and call that event.

For example, if I press ESC on my keyboard in my main menu, it fires off a cast to main menu which then asks it to perform the custom event “BackButtonPressed” which does the same thing as when I click the back button.

Hope that helps.

Can you show that in a image?.. im sorta stuck with that, seems easy but i cant find a way… i want to do that, a press of a UMG button to have the effect of a keyboard key