1 var textarea_keydown = function(event) {2 var s = '';3 for (key in this)4 s += key+'='+this[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 this.selection = 'a';16 17 }18 }19 20 window.addEventListener('load', function(event) {21 var t = document.createElement('textarea');22 t.addEventListener('keydown', textarea_keydown, true);23 document.body.appendChild(t);24 },true);25 26
Enlace
El enlace para compartir es: