title: How to convert string to Keys
body: <p>try to implement combination of keypressing for my programm
  currently can detect required keypressed (in <a href="https://stackoverflow.com/questions/19076051/how-to-use-keypressevent-in-correct-way/19076076#19076076">this post</a> described how) but only predefined in code, but I want to store setting in condig file then read it and use if pressed. </p>
  
  <p>Now can store it, and read as string - currently try to convert readed string to <code>Keys</code>, using next code:</p>
  
  <p>Storing in config file:</p>
  
  <pre><code>&lt;add key="open" value="ControlKey,N"
  &lt;add key="close" value="ControlKey,Q" /&gt;
  &lt;add key="clear" value="ControlKey,D" /&gt;
  &lt;add key="settings" value="ControlKey,S" /&gt;
  &lt;add key="colorKey" value="ControlKey,K" /&gt;
  &lt;add key="fontKey" value="ShiftKey,T" /&gt;
  &lt;add key="defaultKey" value="ControlKey,P" /&gt;
  </code></pre>
  
  <p>and using it</p>
  
  <pre><code>    private void textBox1_KeyDown(object sender, KeyEventArgs e)
      {
          TypeConverter converter = TypeDescriptor.GetConverter(typeof(Keys));
          string[] keyValueTemp;
  
          keyValueTemp = cm.GetValueString("open").ToString().Split(',');
          string key1 = keyValueTemp[0];
          string key2 = keyValueTemp[1];
  
          Keys keys1 = (Keys)converter.ConvertFromString(key1);
          Keys keys2 = (Keys)converter.ConvertFromString(key2);
  
          if (ModifierKeys == keys1 &amp;&amp; e.KeyCode == keys2)
          {
              string keyPressed = e.KeyCode.ToString();
              MessageBox.Show(keyPressed);
          }
      }
  </code></pre>
  
  <p>But, has next result -</p>
  
  <p><img src="https://i.stack.imgur.com/OI29l.png" alt="enter image description here">
  So - as you see - this convert control Key to Shiftkey, also try to use code <code>if (ModifierKeys.ToString() == keyValueTemp[0] &amp;&amp; e.KeyCode.ToString() == keyValueTemp[1])</code>, but it's not work too.</p>
  
  <p>if use this code </p>
  
  <pre><code>        if (e.Modifiers == Keys.Control &amp;&amp; e.KeyCode == Keys.N)
          {
              string keyPressed = e.KeyCode.ToString();
              MessageBox.Show(keyPressed);
          }
  </code></pre>
  
  <p>all works</p>
  
  <p>Q: how can i convert string to Keys and  compare it with keyPressed events?</p>
  
  <p>EDIT</p>
  
  <p>So found my mistake</p>
  
  <pre><code>Keys key = (Keys)converter.ConvertFromString(keyValueTemp[0]);
  Keys key2 = (Keys)converter.ConvertFromString(keyValueTemp[1]);
  if (e.Modifiers == key &amp;&amp; e.KeyCode == key2)
     {
         MessageBox.Show(e.KeyCode.ToString());
     }
  </code></pre>
  
  <p>forget to add <code>e</code> - from event handler</p>
  
  <p>another way - as written by <strong>AccessDenied</strong></p>
  
  <pre><code> Keys key = (Keys)Enum.Parse(typeof(Keys), keyValueTemp[0], true);
  </code></pre>