Text box
{{Short description|Boxes where text is entered in computing}}
{{more citations needed|date=February 2017}}
Image:Textarea text entry box.png]]
A text box also called an input box, text field or text entry box, is a control element of a graphical user interface, that should enable the user to input text information to be used by a program.{{Cite web |title=What does text box mean? |url=https://www.definitions.net/definition/text+box |access-date=2020-08-08 |website=www.definitions.net}}{{Cite web |title=Text Box Definition|url=https://techterms.com/definition/text_box |access-date=2020-08-08 |website=techterms.com}} Human Interface Guidelines recommend a single-line text box when only one line of input is required, and a multi-line text box only if more than one line of input may be required. Non-editable text boxes can serve the purpose of simply displaying text.
A typical text box is a rectangle of any size, possibly with a border that separates the text box from the rest of the interface. Text boxes may contain zero, one, or two scrollbars. Text boxes usually display a text cursor (commonly a blinking vertical line), indicating the current region of text being edited. It is common for the mouse cursor to change its shape when it hovers over a text box.
Standard functionality
Typical implementations allow a user to do the following. (The keys indicated relate to the text box widgets in Microsoft Windows and Mac OS X; similar if not identical keyboard bindings exist under the X Window System and other systems, and typically follow the same scheme as Windows.)
=Enter text=
When keys are pressed on a keyboard, the text appears where the caret is. Some very simple text boxes may not show a caret, which would suggest that new characters typed in will appear at the end of the current text.
=Navigate and manipulate text=
Using a mouse:
- Change the caret position by clicking the desired point with a mouse cursor;
- Select a portion of text by pressing the main mouse button while pointing the cursor at one end of the desired part of the text and dragging the cursor to the other end while holding the button pressed.
Using the keyboard:
- Pressing arrow keys changes caret position by one character or line (in multiline text boxes);
- Pressing {{Key press|Home}} / {{Key press|End}} keys (Microsoft's Windows OS) or {{Key press|Command}}-left arrow / Command-right arrow (Apple's Mac OS) moves the caret to the beginning / end of the line;
- Pressing {{Key press|Page Up}} / {{Key press|Page Down}} moves the caret a page (the number of lines that can be displayed in the text box at a time) backward / forward (Windows) or moves the scrollbar thumb a page backward / forward without changing the caret position (Mac OS);
- Holding the {{Key press|Ctrl}} key (Windows) while pressing arrow keys or {{Key press|Home}} / {{Key press|End}} keys makes the caret move at larger steps, e.g. words, paragraphs or beginning / end of document;
- Holding the {{Key press|Option key}} (Mac OS) while pressing arrows moves the caret whole words or paragraphs;
- Holding the {{Key press|Command key}} while pressing up or down arrows (Mac OS) or Holding the {{Key press|Ctrl}} key while pressing {{Key press|home}} / {{Key press|end}} (Windows) moves the caret to the beginning or end of the document;
- Holding the {{Key press|shift key}} while changing the caret position with a mouse or keyboard selects the text between the caret position from when shift was first pressed and its current position.
- Pressing {{Key press|Control|A}} (Windows) selects all text.
=Edit text=
Work in insert or overwrite mode, typically switched using {{Key press|Insert key}}. In insert mode if there is a character to the right of the caret, the new character will be inserted before it, while in overwrite mode typing a new character will replace (overwrite) the character to the right of the caret position.
Typing in a text while some part of the text already entered is selected will replace the selected text.
{{Key press|Delete}} / {{Key press|Backspace}} keys remove one character right / left of current caret position, while pressing them together with the {{Key press|Ctrl}} or {{Key press|command key}} removes one word.
Edit the text using standard clipboard operations.
Edits can be undone and redone with Control-Z / Control-Y (Windows) or {{Key press|command|Z}} / {{Key press|command|shift|Z}} (Mac OS)