title: Support tabs for indentation in <textarea>
body: <p>I am aware this question has been asked before (<a href="https://stackoverflow.com/questions/6637341/use-tab-to-indent-in-textarea">Use tab to indent in textarea</a>), but the answers provided did not fix my problem. My code is as follows:</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>$(document).ready(() =&gt; {
    document.getElementById('input').onkeydown = e =&gt; {
      if (e.keyCode == 9 || e.which == 9) {
        e.preventDefault();
        var s = this.selectionStart;
        this.value = this.value.substring(0, this.selectionStart) + "\t" + this.value.substring(this.selectionEnd);
        this.selectionEnd = s + 1;
      }
    }
  
    /* This jQuery solution doesn't work, either
              $('#input').keydown(e =&gt; {
                  var keyCode = e.keyCode || e.which;
      
                  if (keyCode == 9) {
                      e.preventDefault();
                      var start = this.selectionStart;
                      var end = this.selectionEnd;
      
                      // set textarea value to: text before caret + tab + text after caret
                      $(this).val($(this).val().substring(0, start)
                                  + "\t"
                                  + $(this).val().substring(end));
      
                      // put caret at right position again
                      this.selectionStart =
                      this.selectionEnd = start + 1;
                  }
              });
              */
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!doctype html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
    &lt;script&gt;
    &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;textarea id="input"&gt;&lt;/textarea&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Browser is Google Chrome 67 on a Mac.</p>