title: change tab key behavior in javascript
body: <p>I'm having a text editor inside a contenteditable div.</p>
  
  <p>I need to change the [TAB] behavior to insert spaces or a \t instead of focusing on next element which is the default browser behavior.</p>
  
  <p>I have an event handler like so:</p>
  
  <pre><code>function keyDown(e) {
      // press tab.
      if (e.keyCode == 9) {
          e.preventDefault();
          return;
      }
  }
  </code></pre>
  
  <p>which results in not losing focus on the div, all i need now is to insert a [TAB] or spaces at the cursor position.</p>
  
  <p>how can this be done?</p>