1 var textarea_keydown = function(event) {2 var s = '';3 for (key in event)4 s += key+'='+event[key]+'\n';5 //alert(s);6 7 if (event.keyCode==9) {8 //event.stopPropagation();9 event.preventDefault();10 11 var startPos = this.selectionStart;12 var endPos = this.selectionEnd; 13 this.value = this.value.substring(0, startPos)+ '\t' 14 + this.value.substring(endPos, this.value.length);15 16 }17 }18 19 window.addEventListener('load', function(event) {20 var t = document.createElement('textarea');21 t.addEventListener('keydown', textarea_keydown, true);22 document.body.appendChild(t);23 },true);24 25
Enlace
El enlace para compartir es: