title: textbox defocuses after pressing tab key followed by any character in Firefox
body: <p>I am trying to make an in-browser HTML editor, similar to CodePen and JSfiddle.I included a test to allow tabs without defocusing the editor. It works fine, except in Firefox. In Firefox, it keeps focus after pressing tab only to lose focus after the next keystroke.</p>
  
  <pre><code>let textbox = document.getElementById("preview-textbox");//textbox used for inserting HTML into iframe
      textbox.value = "";
  
  let iframe = document.querySelector("iframe");//used to render user's code
  
      textbox.addEventListener("input", (e)=&gt;{//inserts html from textbox into the iframe
          iframe.src = "data:text/html," + encodeURI(textbox.value);
      });
      textbox.addEventListener("keydown", (e)=&gt;{//allows indentation with 'tab'
          let cursor_position = textbox.selectionStart;
          let is_tab = e.keyCode || e.which;
          if(is_tab === 9){
              textbox.value = textbox.value.substr(0, cursor_position) + '\t' + textbox.value.substr(cursor_position, textbox.value.length);
              let focus_textbox = setInterval(()=&gt;{
                                              textbox.focus();//refocuses textbox
                                              textbox.selectionEnd = ++cursor_position;//sets cursor position
                                              clearInterval(focus_textbox);}, 30);//clear setInterval
          } 
  
  
      });
  </code></pre>