LNK2001 adding custom FKey

Hello, like many other users I try to implement a custom input device and the tutorials I found here and here
helped me a lot. Everything is working and the log output shows the device values.
But sadly I can’t connect them with FKey Events as shown here. If I try to add a key like this, I end up with an LNK 2001 linker error:

error LNK2001: unresolved external symbol “public: static struct FKey const EMyKeys::MyKey”

// Foo.h
struct EMyKeys
{
	static const FKey MyKey;
};
//Foo.cpp
Foo::StartupModule() {
 [...]
 EKeys::AddKey(FKeyDetails(EMyKeys::MyKey, LOCTEXT("MyKey", "My Key"), FKeyDetails::FloatAxis));
}

The dependencies pointed out by the other posts (e.g., InputCore and Slate) are in the build file as well.

Does anyone might have a solution for this problem? Any help would be really appreciated. Thanks!!

Static member variables are declared in the type, but must be defined out of it - usually this sort of error means you have your declaration but not the definition, which should be placed in the associated cpp file rather than the header to prevent multiple definition errors.
In the wiki example you’ve linked, this is done with the line

const FKey FPseudoControllerKey::Pseudo_WeighingSensor1("Pseudo_WeighingSensor1");

in the PseudoControllerInputDevice.cpp.

Thank you very much :slight_smile: that fixed it