title: how to detect the (Shift+Delete) key press?
body: <p>I'm making a custom Terminal in a C# winform.  When the user presses a key in the <code>TextBox</code> that I'm using I have to make sure that it's a valid key.  I need to prevent them from being able to delete stuff and do whatever they want.  I managed to handle the backspace and delete and others via the <code>KeyPress</code> and <code>KeyDown</code> events.  I had a problem with the user pressing <kbd>shift</kbd> + <kbd>delete</kbd>.  It deletes stuff just like <kbd>backspace</kbd>.  I don't know what the integer equivalent of it is.  I made a C++ program to detect it, it was simple:</p>
  
  <pre><code>char c = _getch();
  cout &lt;&lt; (int)c &lt;&lt; endl;
  </code></pre>
  
  <p>I got a -32.  It didn't work in C#.</p>
  
  <p>After so many tries to encircle its value, I found that it was 0.
  It worked, at least for yesterday, but now it doesn't.  I'm also able to delete stuff with the shift+delete.</p>
  
  <p>Here's my key validation method:</p>
  
  <pre><code>private bool IsInvalidKey(char key)
  {
    bool condition1 = !IsAsciiKey(key) &amp;&amp; !IsNavigatingKey(key); // by navigation I mean: left, right, end and home keys.
    bool condition2 = (GetCaretPosition() == CaretPosition.OutsideCommandLine &amp;&amp; !IsNavigatingKey(key));
    bool condition3 = ((key == (char)Keys.Back) &amp;&amp; GetCaretPosition() == CaretPosition.BeginningOfCommandLine);
    return (condition1 || condition2 || condition3);
  }
  
  private bool IsAsciiKey(char key)
  {
    return ((int)key &gt; 0 &amp;&amp; (int)key &lt;= 127); // char(0) should be shift+delete
  }
  </code></pre>
  
  <p>How can I detect this key and where (in which event, <code>KeyPress</code> or <code>KeyDown</code>?)</p>
  
  <p>I'm using a normal <code>TextBox</code> control, not a <code>RichTextBox</code>.</p>