title: Detect the Tab Key Press in TextBox
body: <p>I am trying to detect the <kbd>Tab</kbd> key press in a <code>TextBox</code>.
  I know that the Tab key does not trigger the <code>KeyDown</code>, <code>KeyUp</code> or the <code>KeyPress</code> events. I found: Detecting the Tab Key in Windows Forms of BlackWasp in the internet.
  They suggest to override the ProcessCmdKey, which I did, but it does not get triggered either.
  Is there a reliable way to detect the Tab Key press?</p>
  
  <pre><code>protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
  {
  
      bool baseResult = base.ProcessCmdKey(ref msg, keyData);
  
      if (keyData == Keys.Tab &amp;&amp; textBox_AllUserInput.Focused)
      {
          MessageBox.Show("Tab key pressed.");
          return true;
      }
      if (keyData == (Keys.Tab | Keys.Shift) &amp;&amp; textBox_AllUserInput.Focused)
      {
          MessageBox.Show("Shift-Tab key pressed.");
          return true;
      }
  
      return baseResult;
  }
  </code></pre>
  
  <p>According to Cody Gray's suggestion, I changed the code as follows:</p>
  
  <pre><code>protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
      {
          if (keyData == Keys.Tab &amp;&amp; textBox_AllUserInput.Focused)
          {
              MessageBox.Show("Tab key pressed.");        }
          if (keyData == (Keys.Tab | Keys.Shift) &amp;&amp; textBox_AllUserInput.Focused)
          {
              MessageBox.Show("Shift-Tab key pressed.");        }
  
          return base.ProcessCmdKey(ref msg, keyData);
      }
  </code></pre>
  
  <p>The problem is that it does not capture the Tab key press.</p>