title: how to create button shortcuts in vbnet
body: <p>I tried creating keyboard shortcuts for my buttons.</p>
  
  <p>Here is my code</p>
  
  <pre><code> Private Sub form_main_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
      If Keys.ControlKey + Keys.N Then
          'btn_add.PerformClick()
          addentry()
      ElseIf Keys.ControlKey + Keys.E Then
          'btn_edit.PerformClick()
          editentry()
      End If
  End Sub
  </code></pre>
  
  <p>The problem is even when I press other buttons the function is still called. I also tried using form <code>keydown</code> property but the result is still the same.</p>
  
  <p>additional info: </p>
  
  <ul>
  <li>the functions <code>addentry</code> and <code>editentry</code> will just call the <code>form_addedit</code></li>
  <li><code>btn_add</code> will call for <code>addentry</code></li>
  <li><code>btn_edit</code> will call for <code>editentry</code></li>
  </ul>