Simulate press key

Could you give a little more detail? Specifically, what you’re trying to do?

For instance, you say “simulate pressing keys on the keyboard.” If you mean doing so fairly literally, so that the whole computer sees the keypress, it’s easy enough to make a Blueprint node to call the general Windows SendKey function, but that’d be specific to Windows. (And given your app would presumably be in the foreground, it would still generally go to your app.)

But that function is finicky at the best of times, and doesn’t work with all methods of getting keyboard input on Windows.

If you’re trying to generate key presses as input inside your Unreal project specifically across all the platforms (including macOS, iOS, Android, etc.)—such as trying to do “press and hold W to move the character forward”—that approach obviously wouldn’t be auitable.

If you’re trying to generate key events just to interact with your widgets specifically, that’s yet another scenario.

Having a little more detail on what you’re trying to actually do will help folks know what it is you’re looking for (and if maybe there’s a better way to achieve it already in the engine).

1 Like