title: Disable keyboard shortcuts when text field or textarea has focus using pure JavaScript
body: <p>I have a simple script that uses left and right arrows to move to next and previous blogpost.</p>
  
  <pre><code>var nextEl = document.getElementById("pagination__next__link");
  var prevEl = document.getElementById("pagination__prev__link");
  
  document.onkeyup = function(e) {
  
      if (nextEl !== null) {
          if (e.keyCode === 37) {
              window.location.href = nextEl.getAttribute('href');
          }
      }
      if (prevEl !== null) {
          if (e.keyCode === 39) {
              window.location.href = prevEl.getAttribute('href');
          }
      }
      return false;
  };
  </code></pre>
  
  <p>But it also works when I have text <code>input</code> or <code>textarea</code> focused. What would be the best way to disable the keyboard shortcuts when focused?</p>
  
  <p>Thanks!</p>