Possible Duplicate:
How to handle <tab> in textarea?
I need a way to maintain tab levels in a textarea, so far this is what I have used:
<script type="text/javascript">
   $("textarea").keydown(function(e) {
      var $this, end, start;
      if (e.keyCode === 9) {
         start = this.selectionStart;
         end = this.selectionEnd;
         $this = $(this);
         $this.val(
            $this.val().substring(0, start)
            + "\t" + $this.val().substring(end)
         );
         this.selectionStart = this.selectionEnd = start + 1;
         return false;
      }
   });
</script>
But this only inserts tabs (I found this on another SO post so I don't really know what it does as I'm not a JS expert )
Is there a way for those tabs to be there when I hit the return key? I need this because I am making a very simple code editor for my admin panel (no need for syntax highlight or anything) and it uses TextAreas.
Thanks!
 
     
    