Foros del Web » Programando para Internet » Javascript » Frameworks JS »

Problema detectando teclas

Estas en el tema de Problema detectando teclas en el foro de Frameworks JS en Foros del Web. Tengo el siguiente codigo: Código PHP: < script language  =  "javascript" >  function  createRequestObject (){        var  peticion ;        var  browser  =  navigator . appName ;              if( ...
  #1 (permalink)  
Antiguo 10/06/2007, 06:14
Avatar de mdk
mdk
 
Fecha de Ingreso: noviembre-2002
Mensajes: 531
Antigüedad: 21 años, 5 meses
Puntos: 11
Problema detectando teclas

Tengo el siguiente codigo:

Código PHP:
<script language "javascript"
function 
createRequestObject(){ 
      var 
peticion
      var 
browser navigator.appName
            if(
browser == "Microsoft Internet Explorer"){ peticion = new ActiveXObject("Microsoft.XMLHTTP"); }
        else{ 
peticion = new XMLHttpRequest(); } 
        return 
peticion

function 
compUsuario(thevaluee) { 
    var 
theextrachar e.which;
    if (
theextrachar == undefined) { theextrachar e.keyCode; }

    if (
theextrachar == 8) {
        if (
thevalue.length == 1) { var serverPage "code2/code.php"; }
        else { var 
serverPage "code2/code.php" "?ltr=" thevalue.substr(0, (thevalue.length -1)); }
    }
    else { var 
serverPage "code2/code.php" "?ltr=" thevalue String.fromCharCode(theextrachar); }
    
    var 
obj document.getElementById("DivDes");
    var 
http = new Array(); 
    var 
act = new Date(); 
    
http[act] = createRequestObject(); 
    
http[act].open('get'serverPage); 
    
http[act].onreadystatechange = function() { 
        if (
http[act].readyState == 4) { 
            if (
http[act].status == 200 || http[act].status == 304) { 
                
obj.innerHTML http[act].responseText;
            } 
        } 
    } 
    
http[act].send(null); 


</script> 
<p>Teclea texto a escribir: 
  <input id="textField" type="text" name="Texto" onkeypress="compUsuario(this.value, event)"> 
</p> 
<div id="DivDes"></div> 
Me funciona correctamente pasandome el texto ke escribo a la capa DivDes, pero el problema es ke cuando le doy a la tecla BackSpace no la detecta y no borra un caracter en la capa DisDes, alguien sabe donde puede estar el fallo, porque me estoy volviendo loco :(
__________________
SoY Lo Ke VeS iNKLuSo KuAnDo No Me VeS ;)
  #2 (permalink)  
Antiguo 12/06/2007, 11:52
Avatar de MaBoRaK  
Fecha de Ingreso: abril-2003
Ubicación: La Paz - Bolivia
Mensajes: 2.003
Antigüedad: 21 años
Puntos: 35
Re: Problema detectando teclas

loading..........


Pues tu código está bien :S ... no entra por la condicional theextrachar==8 ?

prueba parseInt(theextrachar)==8...... no se donde mas podria estar el error


connection closed.
__________________

Maborak Technologies
  #3 (permalink)  
Antiguo 12/06/2007, 15:52
Avatar de mdk
mdk
 
Fecha de Ingreso: noviembre-2002
Mensajes: 531
Antigüedad: 21 años, 5 meses
Puntos: 11
Re: Problema detectando teclas

No, segun he probado no detecta ni esa tecla ni la tecla "tab" no se porque sera, en cambio la tecla esc, si la detecta pero borra toda el campo del formulario...

A alguien se le ocurre alguna solucion?
__________________
SoY Lo Ke VeS iNKLuSo KuAnDo No Me VeS ;)
  #4 (permalink)  
Antiguo 13/06/2007, 07:38
Avatar de MaBoRaK  
Fecha de Ingreso: abril-2003
Ubicación: La Paz - Bolivia
Mensajes: 2.003
Antigüedad: 21 años
Puntos: 35
Re: Problema detectando teclas

loading...............


Te sale undefined o que??

var theextrachar = e.which;
if (theextrachar == undefined) { theextrachar = e.keyCode; }
alert(theextrachar)

Falla tu teclado :p o pon el demo en linea

connection closed.
__________________

Maborak Technologies
  #5 (permalink)  
Antiguo 26/06/2007, 14:28
Avatar de mdk
mdk
 
Fecha de Ingreso: noviembre-2002
Mensajes: 531
Antigüedad: 21 años, 5 meses
Puntos: 11
Re: Problema detectando teclas

No, puse un "chivato" que me dijera el codigo de cada tecla al pulsarla, y me pone el codigo de todo el teclado menos la de Tab, backspace, y un par mas.. :S
__________________
SoY Lo Ke VeS iNKLuSo KuAnDo No Me VeS ;)
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:20.