11

An issue that bothers me a while, which I could never found out:

Is there any key / shortcut that I can use to add an indent by TAB key within an input text field (HTML). Like the one I am writing now :)

Over the years I always took a tab jump (indent) from an editor and pasted it to the necessary position within the textfield.

In other words: Is it necessary to turn off the default tab behaviour to prevent jumping to the next field somehow?

3
  • I guess you could use an AutoHotKey script to set up a keyboard shortcut that would paste a Tab character at the current cursor location.
    – Karan
    Dec 21, 2012 at 19:14
  • 3
    dup superuser.com/questions/67934/…
    – Bratch
    Dec 21, 2012 at 20:34
  • @Bratch Thanks for the hint! Since ALT+09 does not work for me, I will go for the firefox addon tabinta
    – Avatar
    Dec 22, 2012 at 7:48

3 Answers 3

9
  • For Firefox, the Tabinta addon works well. You can change Tab to insert a tab, and even set an alternate key that advances to the next field (the default behavior of Tab).
  • For any Windows program, you can press Alt+09 (press and hold Alt, press and release numpad 0, press and release numpad 9, release Alt) to insert a tab. You can then copy and paste that resulting tab to your heart's content.
  • For any Mac program, you can press ControlOptionTab to insert a tab. Copy and paste it as needed.
0
1

If you want to customize Firefox's default behavior use Tabinta. According to the blurb...

Tabinta lets you insert tab characters in multi-line text input fields. The name itself is a shorthand for "Tab in Textarea".

The default tab key behavior in Mozilla/Firefox textareas is to go to the next form field. This extension is for people who prefer inserting actual tab characters into these fields.

You can alter the default behavior of the Tab key to insert a tab, instead of the usual field tabbing.

Ordinarily, this would be done by the developer of a site using JavaScript...

function keyHandler(e) {
    var tabkey = 9;
    if (e.keyCode == tabkey) {
        this.value += "\t"; \\ could use something like "    " instead
        if (e.preventDefault) {
            e.preventDefault();
        }
        return false;
    }
}
2
  • Thanks for your answer! My question, though, is there a key-combination, a shortcut I could use while typing to do the indent? ... How could I call the function you provided by typing into this textfield?
    – Avatar
    Dec 21, 2012 at 17:28
  • @EchtEinfachTV See my edit. There is a Firefox addon for your situation. Enjoy!
    – Ian Atkin
    Dec 21, 2012 at 19:39
1

Generally, on Mac OS X, you can press CtrlOptTab to insert a tab character instead of switching focus.

At least in well behaved applications. Firefox ignored many other platform conventions as well, so it's not surprising it fails to behave properly in this case.

Not the answer you're looking for? Browse other questions tagged .