Tab key


The tab key on a keyboard is used to advance the cursor to the next tab stop.

History

The word tab derives from the word tabulate, which means "to arrange data in a tabular, or table, form." When a person wanted to type a table on a typewriter, there was a lot of time-consuming and repetitive use of the space bar and backspace key. To simplify this, a horizontal bar was placed in the mechanism called the tabulator rack. Pressing the tab key would advance the carriage to the next tabulator stop. The original tabulator stops were adjustable clips that could be arranged by the user on the tabulator rack. Fredric Hillard filed a patent application for such a mechanism in 1900.
The tab mechanism came into its own as a rapid and consistent way of uniformly indenting the first line of each paragraph. Often a first tab stop at 5 or 6 characters was used for this, far larger than the indentation used when typesetting. For numeric data, however, the logical place for the tab stop is the location of the least significant digit. Tabbing to this location and then pressing the backspace key to back up to the position of the first digit is practical but slow. Various schemes for numeric tabs were proposed. For example, in 1903, Harry Dukes and William Clayton filed for a patent on a tab mechanism with multiple tab keys numbered 1, 10, 100, etc. Pressing 1 was a simple tab. Pressing 10 advanced to the space before the tab, pressing 100 advanced to the position 2 spaces before the tab.
Initially tab stops were set by adding and removing clips from the tab rack, but Edward Hess working for the Royal Typewriter Company filed for a patent in 1904 covering a system where the tab stops were permanently mounted on the tab bar. To set or reset a tab for a particular column, the tab stop for that column was simply rotated in or out of engagement. In 1940, James Koca filed for a patent on a mechanism allowing the tab stops for each column to be set and cleared from the keyboard, eliminating the need for the typist to bend over the back of the machine to directly manipulate the tab rack. These keys, if present, are typically labeled tab set and tab clear.

Modern usage

In word processing and text editing, the Tab key will move the insertion point to the next tab stop in a table, insert the ASCII tab character, or insert multiple space characters.
When filling out a computerized form, pressing Tab will sometimes move the cursor to the next field, eliminating the need to use a mouse to click in an adjacent field.
In many graphical applications, especially on Windows, the Tab key will move the focus to every control or widget such as buttons so that the user interface can be used without a mouse at all. On macOS, this is an option called "Full Keyboard Access".
A feature called tab completion can be used to complete a partially typed piece of text. For example, in some command-line interfaces, you may type the first few characters of a command or file-name, then press Tab. If there is no ambiguity about your intent, the rest of the characters will appear automatically. On some systems, even if your input is ambiguous, tab completion may give you a list of possible options to select from. Tab completion is more common on Linux, Unix, and Unix-like systems than Windows.
In PC video games, the Tab key is very often used to show scores in multiplayer games. For single player games it is also used to show the world map or the player's inventory.
In software engineering, when developing computer programs or storing and manipulating data in files, the Tab character is often used for indentation purposes to help guide the flow of reading and add semantic structure to the code or data. Some programmers and programming languages prefer the usage of multiple whitespace characters instead for that purpose. Because of this, many text editors have an option that makes the tab key insert multiple whitespace characters instead of a tab character.

Tab characters

The most known and common tab is a horizontal tab, which in ASCII has the decimal character code of 9, and may be referred to as or. In C and many other programming languages the escape code can be used to put this character into a string constant. The horizontal tab is usually generated by the Tab key on a standard keyboard.
A vertical tab also exists and has ASCII decimal character code 11, escape character.
In EBCDIC the code for HT is 5. VT is 11.
Originally, printer mechanisms used mechanical tab stops to indicate where the tabs went. This was done horizontally with movable metal prongs in a row, and vertically with a loop of mylar or other tape the length of a page with holes punched in it to indicate the tab stops. These were manually set to match the pre-printed forms that were loaded into the printer. In practice, settable tab stops were rather quickly replaced with fixed tab stops, de facto standardized at every multiple of 8 characters horizontally, and every six lines vertically. A printing program could send zero or more tabs to get to the closest tab stop above and left of where it wanted to print, then send line feeds and spaces to get to the final location. Tab characters simply became a form of data compression.
Despite five characters being the typical paragraph indentation on typewriters at that time, the horizontal tab size of eight evolved because as a power of two it was easier to calculate with the limited digital electronics available. Using this size tab to indent code results in much white space on the left, so most text editors for code, such as IDEs, allow the size of the tab to be changed, and some default to four instead of eight. Disagreements between programmers about what size tabs are correct are common. Modern editors usually have Tab key insert the indentation the programmer wants as spaces or combinations of tabs and spaces.
ISO 6429 includes the codes 136, 137 and 138 that were intended to allow the program to set and clear tab stops. This is rarely used or supported.

Tab-separated values

are a common de facto standard for exporting and importing database or spreadsheet field values. Text divided into fields delimited by tabs can often be pasted into a word processor and formatted into a table with a single command. For example, in Microsoft Word 2010, Insert > Table > Convert Text to Table... is the necessary command, producing a dialog where the user selects further details.
The TSV convention for exporting data may be compared to the alternative comma-separated values convention.
Gopher menus use tab-separated values to indicate selectors.
TSV has also been cited in a modern approach to solving the programming debate regarding the use of tabs and spaces for code alignment called elastic tabstops. This idea uses a scheme called tab-separated columns rather than the similar tab-separated values.

HTML

In HTML the horizontal tab is coded using or but as with all whitespace characters in HTML, this will be displayed as a single space except inside, tags.
Here is an example:

;HTML:

This line begins with a single tab.
Here are some more tab characters !
T.......T.......T.......T.......T.......T.......T.......T

;Inside :

This line begins with a single tab.
Here are some more tab characters !
T.......T.......T.......T.......T.......T.......T.......T

;Outside :

This line begins with a single tab.
Here are some more tab characters !
T.......T.......T.......T.......T.......T.......T.......T

Notice that the tab at the start of a line is removed outside, the eight-character spacing, and how a tab stop is skipped if there are more than 8 characters since last one.
CSS 3 defines property, which adjusts the number of spaces for the tab character from the default of eight. The latest version of WebKit supports the property. The Opera web browser supports the CSS property, the Firefox web browser supports the CSS property with the same meaning.
The vertical tab is but is not allowed in SGML; this includes XML 1.0 and HTML.

Unicode

The Unicode code points for the tab character, and the more rarely used vertical tab character are copied from ASCII:
The tab characters can be graphically represented by special symbols:
Unicode also has characters for the symbols to represent or be printed on the tab key: