How do I simulate a keypress

I have done the standard bindings for input with buttons like W for walking forward. What I’m trying to do is write some tests around it now and I’m trying to do it in blueprints. I need to be able to, via blueprints, “press” the W key. So far I haven’t figured out how to do this.

I have wired up my tests to use delegates but those are a little clunky for a designer that doesn’t code to use. I’m trying to turn this into a little BDD framework in blueprints so the rest of our team can define features as tests and then the programmers can implement them and when the tests pass the we know the feature is to spec.

Also, these are integration tests, not unit tests, so the only thing I should be mocking is the input layer. Yet another reason I don’t want to use the delegates because then we are calling the functions directly.

I had a though and did some digging down a different route. I think I will be able to make a wrapper around the InputKey() function on the player controller and just make a testing player controller. Or I can just use the engine source and make the changes there.

@Epic, is there any way we can get this function exposed to BP?

When I’m done with this BDD framework I want to be able to bring it to the market place but if I’m using C++ I can’t publish it and even if I could it’s not accessible to a large portion of the devs that would want it.

My previous idea worked. I just added a wrapper around the player controller and exposed the InputKey functions so I can call them from BP.

I have also started a thread to talk about testing in blueprints if anyone is interested:

Hi, I would need this exact same function but I don’t know how to program it in C++, can you help me? I need to simulate some keyboard key press…