Jump to content

User:AoV2/tabs in textarea

From Wikipedia, the free encyclopedia

This script allows users to type a literal tab character into wpTextbox1 rather than jumping out of it. ―AoV² 22:32, 23 March 2010 (UTC)

To-do

[edit]
  • Make it do this only on pages with a suffix indicating a programming language or (for other pages) when cursor is within a <pre> element or similar.

Code

[edit]
function intercept(e){
	if(e.keyCode == 9) { // U+0009 CHARACTER TABULATION
		insertTags("\t", "", "");
		return false;		
		}		
	else return true;
	}

function literal_tab_in_textarea() {
	t = document.getElementById("wpTextbox1");
	if(t) t.onkeydown = intercept;
	}

addOnloadHook(literal_tab_in_textarea);