UMG with WASD navigation

Hi, how do I add WASD navigation on buttons umg? Input settings doesn’t add the keys.

Do I use the umg override key down or maybe some other method?

thanks

bump thread

You have to set up custom input handling on your widgets to do that. Or to allow joystic support.

If you have access to the engine source you can edit the following file; “/Engine/Source/Runtime/Slate/Private/Framework/Application/NavigationConfig.cpp”

Add the following to “FNavigationConfig::FNavigationConfig()”

KeyEventRules.Emplace(EKeys::A, EUINavigation::Left);
KeyEventRules.Emplace(EKeys::D, EUINavigation::Right);
KeyEventRules.Emplace(EKeys::W, EUINavigation::Up);
KeyEventRules.Emplace(EKeys::S, EUINavigation::Down);

I’m sure there are better ways to do this but I’ve only just started to go beyond blueprints and this works for me using UE4.27.2

1 Like

If you don’t have access to engine source

No idea if this is a good way of doing it, but this worked for me.

I implemented the following in my PlayerController base class.

#include "Framework/Application/SlateApplication.h"

void APlayerController_Base::BeginPlay() {

Super::BeginPlay();
FSlateApplication::Get().GetNavigationConfig().Get().KeyEventRules.Emplace(EKeys::A, EUINavigation::Left);
FSlateApplication::Get().GetNavigationConfig().Get().KeyEventRules.Emplace(EKeys::S, EUINavigation::Down);
FSlateApplication::Get().GetNavigationConfig().Get().KeyEventRules.Emplace(EKeys::W, EUINavigation::Up);
FSlateApplication::Get().GetNavigationConfig().Get().KeyEventRules.Emplace(EKeys::D, EUINavigation::Right);
}

Hope this helps!

3 Likes

I know this is an older topic, but where do I locate the PlayerController base class in the engine files if I dont have source access?
I dont see that in the /All/Engine files at all when I show Engine Content
UE 5.3.1

It doesn’t work for me, any idea why? Same version.

If you installed the engine through the EPIC launcher editing source code will not make any difference. Would advice against branching this engine though, it’s easier just to make your own class and inject it into Slate with the new keys injected. This is how I do it, but the emplace used by Panundrum looks fine.

FSlateApplication::Get().SetNavigationConfig(MyNewSlateNavigationConfig);
FCustomSlateNavigationConfig::FCustomSlateNavigationConfig() {
	KeyEventRules.......
	KeyActionEventRules......
}

If you are a blueprint user you won’t see it. As a C++ user you go into visual studio and search for APlayerController. In both C++ and Blueprint you can create a new class inheriting from APlayerController and override / implement what you need in there, no need for editing source.

1 Like