title: Suppress keydown where there is a confirm() box before return false;
body: <p>I have a massive Javascript file capturing various keydowns on various screens of an application. I always use <code>return false();</code> to prevent the default keydown action from occurring, which works great.</p>
  <p>However, on this particular keydown, there is a <code>confirm()</code> box before the <code>return false;</code>. If I hit <kbd>C</kbd>, the <code>confirm()</code> dialogue comes up. If I move that out of the way, underneath it, the <code>c</code> has already been written to the text box.</p>
  <p>How can I successfully suppress the <code>keydown</code>? This is only required to work in Chrome.</p>
  <pre><code>document.onkeydown = keyDown;
  
  function keyDown()
  {
      switch(window.event.keyCode)
      {
          case(67):
              if(confirm('You have unsaved data! Press OK to Save or Cancel to Discard')) {
                  alert('Do something...');
              }
              else {
                  return false;
              }
              window.location = '/invoice-12345';
              return false;
          break;
      }
  }
  </code></pre>