title: Implementing key press with JS and jQuery
body: <p>I want on a key press an alert box will get displayed. It is done. But the problem is I have a textbox inside the page and when I am trying typing inside the textbox then also the alert box is coming.</p>
  
  <pre><code>$(document).ready(function() {
      $(document).keydown(function(e) {
          if (e.key == "F8") {
              alert('Right key pressed');
          } else {
              alert("Error key pressed")
          }
          e.preventDefault();
      })
  });
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;input type="text" /&gt;
  </code></pre>