views:

23

answers:

1

By default tab symbol in textarea equals to the width of 8 spaces. Is it possible to change this value to 4 for example?

I am mostly interested in using this in Chrome browser.

+3  A: 

The only way you could achieve this is to capture the keyboard onkeyup event, check if a tab was pressed, insert 4 spaces and stop/cancel the event at that point.

Oded
+1 That seems to be the only possibility.
Sarfraz
Pressing tab doesn't insert a tab, it moves to the next form field. For this reason it's unusual to get a tab in a textarea at all. Typically it only happens on copy-and-paste from another application. One could check `onpaste` (or, more reliably, poll) and sniff for tab characters in the field, replacing them with spaces.
bobince