el codigo funciona perfectamente pero en firefox no se puede usar e.keyCode sino e.which
Ya casi lo tengo solucionado con esta funcion:
Código:
if(e.which) // Netscape/Firefox/Opera
{
tecla = e.which;
if(tecla==13)
{
field = document.getElementById('modificar');
startPos = field.selectionStart;
endPos = field.selectionEnd;
before = field.value.substr(0, startPos);
selected = field.value.substr(field.selectionStart, (field.selectionEnd - field.selectionStart));
after = field.value.substr(field.selectionEnd, (field.value.length - field.selectionEnd));
field.value = before + selected + '<p>' + after;
}
}
Ahora el unico problema lo tengo en que cuando añade el <p> el cursor se me pone al final del texto del textarea.