title: Windows Form Calculator - Numpad Keys For Input
body: <p>I am currently in the middle of learning c# for my job, I have been trying some starter projects and i decided to make a calculator, I have all of the functions of a simple calculator working, however i can not get the numpad keys to work with a keypress event or a keydown event, I am wondering if someone can help me in some detail, i am wanting to sett all of the numpad keys to the corrspondings ones on the calculator, here is the code i have tried for the keypress event and i have also tried this with numpad lock on and off.</p>
  
  <pre><code> private void n1_KeyPress(object sender, KeyPressEventArgs e)
      {
          if (e.KeyChar = '1')
          {
              e.Handled = true;
              n1.PerformClick();
  
          }
  
      }
  </code></pre>
  
  <p>Just a quick edit, i have tried to follow MSDN example and include the following</p>
  
  <p>private void n1_KeyDown(object sender, KeyEventArgs e)
          {</p>
  
  <pre><code>        if (e.KeyCode &lt; Keys.D0 || e.KeyCode &gt; Keys.D9)
          {
              if (e.KeyCode &lt; Keys.NumPad0 || e.KeyCode &gt; Keys.NumPad9)
              {
                  nonNumberEntered = true;
              }
          }
  </code></pre>
  
  <p>And still no success</p>