title: How can I handle a customizable hotkey setting?
body: <p>I'm trying to let my app's users an option to set a keyboard hotkey for for some feature.</p>
  
  <p>Right now I'm using a <code>TextBox</code> with the <code>KeyDown</code> event as follows:</p>
  
  <pre><code>Key Hotkey;
  private void SetHotKey(object sender, KeyEventArgs e)
  {
      (sender as TextBox).Text = e.Key.ToString();
      Hotkey = e.Key;
      e.Handled = true;
  }
  </code></pre>
  
  <p>The problem with this approach is I can't set complex shortcuts, like [Ctrl]+[F4]. Is there some 3rd-party control that helps with that? Or a better-suited event to subscribe to on a textbox?</p>
  
  <p><strong><em>UPDATE:</em></strong> I've changed my code but it seems I'm still doing something wrong.</p>
  
  <pre><code>Key Hotkey;
  bool lControl = false;
  bool lAlt = false;
  bool lShift = false;
  private void SetHotKey(object sender, KeyEventArgs e)
  {
      var k = e.Key;
      if (e.IsDown)
      {
          var tb = sender as TextBox;
          tb.Text = "";
          lControl = Keyboard.IsKeyDown(Key.LeftCtrl);
          lAlt = Keyboard.IsKeyDown(Key.LeftAlt);
          lShift = Keyboard.IsKeyDown(Key.LeftShift);
          if (lControl) tb.Text += "Ctrl+";
          if (lAlt) tb.Text += "Alt+";
          if (lShift) tb.Text += "Shift+";
          tb.Text = e.Key.ToString();
          Hotkey = e.Key;
      }
      e.Handled = true;
  }
  </code></pre>
  
  <p>How can I make it work and look cleaner as well?</p>