Adding a custom key

Hello,
I have created a custom input device, but I cannot manage to insert my custom key. I have tried this: How do you integrate a custom input device with the engine input and axis mappings? - Programming & Scripting - Epic Developer Community Forums
But it’s not working.
I have created a struct:

struct MyControllerKey
{
	static const FKey Key1;
	static const FKey Key2;
};

And I have added the new key in CreateInputDevice method, but the AddKey method does not work (link error):

virtual TSharedPtr<class IInputDevice> CreateInputDevice(const TSharedRef<FGenericApplicationMessageHandler>& InMessageHandler)
{
    	EKeys::AddKey(FKeyDetails(MyControllerKey::Key1, LOCTEXT("Key1", "Key1"), FKeyDetails::GamepadKey));
    	return MakeShareable(new FControllerInputDevice(InMessageHandler));
}

This line also gives me problem too, because the first parameter want a FGamepadKeyNames and not a FKey:

FSlateApplication::Get().OnControllerButtonPressed(MyControllerKey::Key1, 0, 0);

Any help or examples would be awesome, thanks!

Add answer for this old question since I had the same problem.

Consider you have FControllerInputDevice.h and FControllerInputDevice.cpp

In FControllerInputDevice.h:

namespace YourNameSpace {

static const FKey Key1("YourKeyName1");    // must have name string
static const FKey Key2("YourKeyName2");

}

In FControllerInputDevice.cpp, constructor:

EKeys::AddKey(FKeyDetails(YourNameSpace::Key1, LOCTEXT(“YourKeyName1”, “Display name of key1”), FKeyDetails::GamepadKey)); // add key of Gamepad

EKeys::AddKey(FKeyDetails(YourNameSpace::Key2, LOCTEXT(“YourKeyName2”, “Display name of key2”), FKeyDetails::FloatAxis)); // add key of Keyboard axis

Then you can see key “YourKeyName1” in Engine-Input-Gamepad, “YourKeyName2” in Engine-Input-Keyboard.