title: Detect pressed modifier keys without triggering keyboard or mouse events
body: <p>My app changes its state when a person holds modifier keys (Shift, Alt, Ctrl). I track modifier keys using keydown/keyup events:</p>
  
  <pre><code>var altPressed;
  window.onkeydown = window.onkeyup = function(e) {
      altPressed = e.altKey;
  }
  </code></pre>
  
  <p>Keyboard events don’t trigger outside of the browser tab. Now, imagine the following scenario:</p>
  
  <ol>
  <li>Hold Shift key</li>
  <li>Click on a link to my app, it will open in a new window</li>
  <li>Release Shift key</li>
  </ol>
  
  <p><code>keyup</code> event won’t fire on my page when it isn’t focused so my app will show when I focus on my app’s tab again it will show the Shift key still being pressed.</p>
  
  <p>Would be nice if <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API">page visibility events</a> had modifier key properties. Alas, they don’t.</p>
  
  <pre><code>document.addEventListener('webkitvisibilitychange', function(e) {
      if (document.webkitHidden) return;
  
      e.altKey // undefined :(
  
  }, false);
  </code></pre>