title: To check/uncheck the checkbox using keyboard in javascript?
body: <p>I'm trying to let the user check/uncheck the checkbox on hitting either spacebar or enter in keyboard, I want to achieve this functionality using JavaScript function.</p>
  
  <p>This is how my code looks partially:</p>
  
  <pre><code> &lt;span class="sample" onClick="UdateComponent" tabindex="0" role="checkbox" aria-checked="" aria-decribedby=""&gt;
  </code></pre>
  
  <p>Inside this span I want to include onkeypress or onkeydown for achieving the functionality that is mentioned above and the constraint is I only have to use JavaScript for this. </p>