Home
About
Contact
Categories
Classic ASP (28 - Sub-Categories)
CSS (1 - Sub-Category)
JavaScript (4 - Sub-Categories)
Databases (22 - Sub-Categories)
ASP.NET (23 - Sub-Categories)
Delphi (5 - Sub-Categories)
Windows Server Core (3 - Sub-Categories)
VMWare (1 - Sub-Category)
Code Editing Tools (2 - Sub-Categories)
Linux (2 - Sub-Categories)
Dell Servers (15 - Sub-Categories)
Bug Reports
(Bugs Fixed
New CFFCS Coding Source is still in Beta
Please report any errors to the [Contact] page. Thank you.
Classic ASP (28)
CSS (1)
JavaScript (4)
Databases (22)
ASP.NET (23)
Delphi (5)
Windows Server Core (3)
VMWare (1)
Code Editing Tools (2)
Linux (2)
Dell Servers (15)
Resources
[View The Source Code For This Project]
Format SQL Script
JavaScript
How-To
Use the tab key in a textarea
HTML
Type in some words with a tab between them to get what we have below. You can also edit the CSS. Click on the [CSS Tab] and edit the textarea style. <textarea id="Mytextarea"> Hello test this out here </textarea>
CSS
#Mytextarea{ width:23.5em; height:10em; }
JavaScript
JS
document.getElementById('Mytextarea').addEventListener('keydown', function(e) { if (e.key == 'Tab') { e.preventDefault(); var start = this.selectionStart; var end = this.selectionEnd; // set textarea value to: text before caret + tab + text after caret this.value = this.value.substring(0, start) + "\t" + this.value.substring(end); // put caret at right position again this.selectionStart = this.selectionEnd = start + 1; } });
Preview
Tags
Use the tab key in a textarea
Event Listener
keydown function
HTML document