I am programmatically generating keypressed event in WPF using this code:
new KeyEventArgs(Keyboard.PrimaryDevice,
Keyboard.PrimaryDevice.ActiveSource,
0, args.Key)
{
RoutedEvent = Keyboard.KeyDownEvent
}
where args.Key is the argument of the KeyUphandler of my WPF usercontrol.
Further I am trying to convert this WPF Key into a Win32 Virtual-Key using KeyInterop.VirtualKeyFromKey method like this:
var keyData = (Keys)KeyInterop.VirtualKeyFromKey(e.Key == Key.System ? e.SystemKey : e.Key);
This method is working fine for normal keys but it is not working for F10 key ( I am getting keydata as None for F10). Any help would be great.