Mapping the enter key to a button in HTML/CSS/JS
<p>I have a small form in which you have to submit a score, which is a number, then i have a script which processes the number. </p>

<p>The form is like so:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form  name ="input2" style="margin-left: 30%; margin-right: 30%; margin-bottom:5%"&gt;
  Score:
  &lt;input type="text" id="score" name="score" maxlength="3" onkeydown="if(event.keyCode==13) changePlayer();" patern="\d"&gt;&lt;br&gt;
  &lt;input id = "submit" type="button" value="Submit" name="Submit" class="btn btn-primary" onclick="changePlayer(); return false"/&gt;
  &lt;input type="button" name="Cancel" class="btn btn-primary" value="Cancel"/&gt;
&lt;/form&gt;</code></pre>
</div>
</div>
</p>

<p>I enter the number in a text box, and then when i click the submit button, the function processes the number. The thing is, i want the same thing to happen when i press enter, but instead, the page refreshes, and the whole thing starts over, i lose the data. </p>

<p>How can i sort of map the enter key to the button, or the function, without it refreshing the page?</p>