title: Javascript Intercepted "Ctrl+O" Does Not Open My File Dialog
body: <p>I have an <code>&lt;input type="file" id="browse-button"/&gt;</code> file-browser input in my HTML.</p>
  
  <p>I have another button with ID <code>choose-file-button</code> that, when clicked, calls <code>document.getElementById("browse-button").click();</code>. When this button is clicked, it correctly clicks <code>#browse-button</code> and the file dialog opens.</p>
  
  <p>Now, I took code from <a href="https://stackoverflow.com/a/14180949/2150749">this answer</a> to intercept a <code>Ctrl+O</code> keypress and open my file dialog, so I have this:</p>
  
  <pre><code>$(window).bind('keydown', function(e)
  {
      if (e.ctrlKey || e.metaKey)
      {
          switch (String.fromCharCode(e.which).toLowerCase())
          {
              case 's':
                  e.preventDefault();
                  // doesn't matter for this question
                  return false;
              case 'o':
                  e.preventDefault();
                  document.getElementById("choose-file-button").click();
                  return false;
          }
      }
      return true;
  });
  </code></pre>
  
  <p>As you can see, when I intercept <code>Ctrl+O</code> I click on my <code>#choose-file-button</code> button, which calls <code>document.getElementById("browse-button");</code> in its <code>onclick</code> handler. I have put a breakpoint in this click handler, and when I press <code>Ctrl+O</code> it does arrive at this breakpoint. However, the file dialog never shows up.</p>
  
  <p>Through debugging, I found out that if I put an <code>alert(...);</code> after the <code>#choose-file-button click()</code> line, then the alert shows up <strong>and</strong> the normal page "Open File" dialog shows up (not my file dialog). If I do not have this alert, however, nothing shows up at all.</p>
  
  <p>Is this a bug? How can I fix it and make my file dialog show up via the intercepted <code>Ctrl+O</code>?</p>
  
  <p>Edit: I just tested in Chrome, and it works perfectly. However, it still does not work in Firefox.</p>