I\'ve found this answer which look like what I need:
How can I programmatically generate keypress events in C#?
Except for the fact I can\'t create an insta
If anyone is trying to create the KeyEventArgs for use in a unit test you'll find that Keyboard.PrimaryDevice.ActiveSource is null.. and throws an exception when you try to use it.
Mocking a PresentationSource is a workable solution (requires sta):
[Test]
[RequiresSTA]
public void test_something()
{
new KeyEventArgs(
Keyboard.PrimaryDevice,
new Mock().Object,
0,
Key.Back);
}