title: How to capture the spacebar press event using KeyeventHandler?
body: <p>I have a Form with a rich text box in which i want to do the following:</p>
  
  <p>When user presses the spacebar button (Currently i am doing it with keydown event but want to use key press event but it doesn't provide e.keycode), a function should be called in which this logic is to be implemented:</p>
  
  <p>last written word is to be fetched and is to be looped through the text of rich text box in order to find its number of occurrences in a rich text box.</p>
  
  <p>What i have done so far is:</p>
  
  <pre><code>private void textContainer_rtb_KeyDown(object sender, KeyEventArgs e)
      {
          if (e.KeyCode == Keys.Space)
          {
              String abc = this.textContainer_rtb.Text.Split(' ').Last();
              chkWordRepeat(abc);
          }
      }
  public void chkWordRepeat(String lastWordToFind)
      {
          int count = new Regex(lastWordToFind).Matches(this.textContainer_rtb.Text.Split(' ').ToString()).Count;
          MessageBox.Show("Word: " + lastWordToFind + "has come: " + count + "times");
      }
  </code></pre>
  
  <p>Please let me know if the above mentioned logic is correct or not And how can i attach this logic with key press event for spacebar? If not then please help me implementing! </p>
  
  <p>Thanks in advance.</p>