title: Can't get keyboard combinations to work on Firefox
body: <p>I have created the following function, which I apply to various inputs in order to restrict what the user can enter in them. While this function is working fine on <strong><code>Microsoft Edge</code></strong>, I'm facing serious resistance from <strong><code>Mozilla Firefox</code></strong> which doesn't seem to accept the combinations <kbd>shift + &larr;</kbd>, <kbd>shift + &rarr;</kbd>, <kbd>ctrl + A</kbd> as well as individual keys such as <kbd>shift</kbd>, <kbd>backspace</kbd>, <kbd>delete</kbd>, etc.</p>
  
  <p>I have mended the second issue and managed to make <strong><code>Firefox</code></strong> accept the individual keys by using the <strong><code>isAuxiliaryKey</code></strong> variable shown below, but I can't find a way to make it accept the combinations. It seems like Firefox's <strong><code>keypress</code></strong> functions like a <strong><code>keydown</code></strong>...</p>
  
  <p>I really want to fix this issue as these combinations are some very common ways to select the text. Is there a way to counter that <em>malfunction</em>?</p>
  
  <p><strong>Code:</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>/* ----- JavaScript -----  */
  function restrict (el, acceptedChars, maxLength) {
    el.onkeypress = function(e) {
      var
        key = String.fromCharCode(e.which),
        isAccepted = isAuxiliaryKey || ((acceptedChars instanceof RegExp) ?
            acceptedChars.test(key) : !!~acceptedChars.indexOf(key)),
        isMaxOrLess = maxLength &gt; el.value.length,
        isAuxiliaryKey =
            (!!~[8, 9, 13, 16, 17, 18, 35, 36, 37, 38, 39, 40, 46].indexOf(e.which)),
        hasActiveSelection = 
            el === document.activeElement &amp;&amp; el.selectionStart !== el.selectionEnd;
  
      return (isAccepted &amp;&amp; (isMaxOrLess || hasActiveSelection)) || isAuxiliaryKey;
    }
  }
  
  restrict(document.getElementById("text"), /[a-z]/, 4);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!----- HTML -----&gt;
  &lt;input id="text" type="text" /&gt;</code></pre>
  </div>
  </div>
  </p>