title: How to stop element with first onclick event to be fired when enter key is pressed first time
body: <p>I was fixing a bug in a jsp page in which even though a function is defined with <code>onkeypress</code> event to click a particular button (actually its an image of button with <code>onclick</code> property associated with it) when the page is opened first time and then enter key is pressed its throwing an error.</p>
  
  <p>When I debugged the code then I find out that actually two calls are made simultaneously.  i.e. the first button with <code>onclick</code> property is also clicked.</p>
  
  <p>Here is just a sample code: </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div onkeypress =handleEnter()&gt;
  name &lt;input  type="text" src='Create.gif' &gt;
  &lt;/br&gt;
  &lt;input  type="image" src='Create.gif' onclick="alert('not done')"&gt;
  &lt;input  type="image" src='Create.gif' onclick="alert('done')"&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;script&gt;
  function handleEnter()
  {
  if(window.event.keyCode==13)
  {
  alert('nothing');
  event.cancelBubble=true;
  }
  }
  &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>on pressing enter key both functions are getting called.</p>