title: Javascript How to use onclick function also with keyboard
body: <p>I hope the title of the question fits to what I'm asking here.</p>
  
  <p>I have this code in HTML &amp; javascript:</p>
  
  <pre><code>&lt;button id="Z"&gt;Z&lt;/button&gt;
  
  var btnZ = document.getElementById("Z");
  btnZ.onclick = function() {
  // Some code
  </code></pre>
  
  <p>Ok, now I want to execute btnZ.onclick function when the user press "Z" on keyboard. How can I do this without duplicating the code inside btnZ.onclick function?</p>