title: Convert KeyChar to Key
body: <p>How can I convert a <code>KeyPressEventArgs.KeyChar</code> to <code>Key</code>?</p>
  
  <p>Casting does not work... see here:</p>
  
  <pre><code>private void textBox_console_KeyPress(object sender, KeyPressEventArgs e)
  {
  
      var key_char = e.KeyChar.ToLower(); //w
  
      var pressed_key = (Key)(key_char); //RightCtrl
      var key_check = Keyboard.IsKeyDown(pressed_key);
  }
  </code></pre>
  
  <p>If in this example, I press <code>w</code>, which has a value of 119, <code>key_check</code> will be <code>false</code> because <code>(Key)(e.KeyChar)</code> will evaluate to <code>RightCtrl</code>.</p>
  
  <p>I need to convert the <code>e.KeyChar</code> to a <code>System.Windows.Input.Key.W</code>, which has a value of 66.</p>