title: Javascript fires two events - onkeypress and onclick
body: <p>Problem is when I press a key over a radio button, element <code>MyFunc</code> fires twice - once for <code>onkeypress</code> event, another time for &quot;click&quot; event.</p>
  <p>Question &quot;Why?&quot; I need to handle this by two different ways, but now I can not recognize what initial event was. When I click a mouse it fires just for &quot;click&quot; event.</p>
  <pre><code>&lt;ul&gt;
      &lt;li&gt;
          &lt;input type=&quot;radio&quot; onkeypress=&quot;MyFunc(event, this)&quot; onclick=&quot;MyFunc(event, this)&quot; name=&quot;myList&quot; id=&quot;MyId_1&quot; /&gt;Topic 1
          &lt;input type=&quot;radio&quot; onkeypress=&quot;MyFunc(event, this)&quot; onclick=&quot;MyFunc(event, this)&quot; name=&quot;myList&quot; id=&quot;MyId_2&quot; /&gt;Topic 2
      &lt;/li&gt;
  &lt;/ul&gt;
  
  function MyFunc(e, obj) {
      alert(e.type); // alerts &quot;keypress&quot; and then &quot;click&quot;
      // Do my stuff
  }
  </code></pre>