Does anyone know a cross-browser, reliable solution for catching presses of the tab-key in a textarea field, and replacing (in the correct position) 4 spaces? The textarea is being used to input an essay, and needs this feature.
Note: I tried using FCKEditor, among others, which did not catch tabs and had a bunch of features I didn't need. I want a simple solution just for catching tabs.
Is there some reason you can't just replace the tabs after the editing is done? I've played around quite a bit with replacing text while typing in a textarea, and found it to be... impractical at best.
I didn't test extensively, but this seems to work:
(I found the "insertAtCursor" function at http://alexking.org/blog/2003/06/02/inserting-at-the-cursor-using-javascript#comment-3817)
EDIT: Modified the script so it doesn't use jQuery.