Accessing Editor Keybindings in C++

Hello, I am working on an editor tool that will help validate Unreal projects for my team (a checklist of everything that needs to be correct for the project/levels/actors)

I want to be able to get the values of the editor keybindings, specifically “Save Current level”, to see if it is bound or not

A search of the API turns up UUnrealEdKeyBindings | Unreal Engine 5.6 Documentation | Epic Developer Community

which has an array of KeyBindings, if this is it it would be helpful for me to see an example of how to access it.

Hi,

Hope you’re doing well.

Try to use the UUnrealEdOptions in order to get UUnrealEdKeyBindings, so you can get the array and check it, e.g.:

void UCustomEditorExample::SimpleEditorKeyBindCheck()
{
	UUnrealEdOptions* Options = GetMutableDefault<UUnrealEdOptions>();
	if (Options)
	{
		UUnrealEdKeyBindings* KeyBind = Options->EditorKeyBindings;
		if (KeyBind)
		{	
			for (const FEditorKeyBinding Binding : KeyBind->KeyBindings)
			{
				UE_LOG(LogTemp, Log, TEXT("Command: %s, Key: %s"), *Binding.CommandName.ToString(), *Binding.Key.GetDisplayName().ToString());
			}
		}
	}
}

if it works, you can improve this function to a bool function which return if some command is bound, like: bool IsSaveLevelBound() const.

Hope that helps - take care!

1 Like