title: How to create a KeyEventArgs object in WPF ( related to a SO answer )
body: <p>I've found this answer which look like what I need: </p>
  
  <p><a href="https://stackoverflow.com/questions/1645815/how-can-i-programmatically-generate-keypress-events-in-c/1646568#1646568">How can I programmatically generate keypress events in C#?</a></p>
  
  <p>Except for the fact I can't create an instance of <code>KeyEventArgs</code> ( I don't know how ) </p>
  
  <p>The code in question is: </p>
  
  <pre><code> var key = Key.Insert;                    // Key to send
    var target = Keyboard.FocusedElement;    // Target element
    var routedEvent = Keyboard.KeyDownEvent; // Event to send
  
    target.RaiseEvent(
      new KeyEventArgs(
        Keyboard.PrimaryDevice,
        PresentationSource.FromVisual(target), //&lt;--- HERE, I can't
        0,
        key)
      { RoutedEvent=routedEvent }
    );
  </code></pre>
  
  <p>The compiler says: </p>
  
  <pre><code>The best overloaded method match for
  'System.Windows.PresentationSource.FromDependencyObject(System.Windows.DependencyObject)'
   has some invalid arguments
  </code></pre>
  
  <p>The ide says: </p>
  
  <p>Argument type <code>IInputElement</code> is not assignable to parameter type <code>DependencyObject</code></p>
  
  <p>And across StackOverflow I've found several answers directing to that answer but none of them address how to create the instance in first place.</p>
  
  <p>How can I do that?</p>