Foros del Web » Programando para Internet » Jquery »

[SOLUCIONADO] manejo del teclado con jquey

Estas en el tema de manejo del teclado con jquey en el foro de Jquery en Foros del Web. hola amigos¡¡¡ estoy trabajando con jQuery JavaScript Library v1.4.4 con la función de manejo del teclado. <script src="/sistema/js/jquery.min.js"></script> <script language="JavaScript"> $(function(){ $("input[type=text]").keydown(function(e){ if (e.keyCode == ...
  #1 (permalink)  
Antiguo 13/02/2014, 17:55
 
Fecha de Ingreso: marzo-2009
Mensajes: 32
Antigüedad: 15 años
Puntos: 3
Pregunta manejo del teclado con jquey

hola amigos¡¡¡

estoy trabajando con jQuery JavaScript Library v1.4.4
con la función de manejo del teclado.

<script src="/sistema/js/jquery.min.js"></script>
<script language="JavaScript">
$(function(){
$("input[type=text]").keydown(function(e){
if (e.keyCode == 13) {
var tabIndex = parseFloat($(this).attr("tabindex")) + 1;
$("input[tabindex=" + tabIndex + "]").focus();
return false;
}
if (e.keyCode == 27) {
window.close();
return false;
}
})
})

La función anda perfecto con los input type="text" pero tengo que implementar un select con 3 opciones y al seleccionar un valor y darle enter no me funciona como con los input text.

tienen alguna idea de como solucionarlo???

Gracias...

adjunto el formulario completo...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<script src="/sistema/js/jquery.min.js"></script>
<script language="JavaScript">
$(function(){
$("input[type=text]").keydown(function(e){
if (e.keyCode == 13) {
var tabIndex = parseFloat($(this).attr("tabindex")) + 1;
$("input[tabindex=" + tabIndex + "]").focus();
return false;
}
if (e.keyCode == 27) {
window.close();
return false;
}
})
})
</script>
</head>
<div class="Estilo1" align="center"><strong>CHOFERES</strong></div>
<font color="red"> <b> Todos los campos con "*" son OBLIGATORIOS </b> </font>
<div id="Layer2">
<form name="form1" method="post" action="">
<label class="Estilo2">Movil</label>
<input name="" type="text" readonly="true" tabindex="1" size="3">

<label class="Estilo2">Nombre
<input type="text" name="textfield" tabindex="2" size="35" autofocus>
</label>
<font color="red"> <b> * </b> </font>

<label class="Estilo2">Direccion
<input type="text" name="textfield" tabindex="3" size="35">
</label>
<font color="red"> <b> * </b> </font>

<label class="Estilo2">Localidad
<input type="text" name="textfield2" tabindex="4">
</label>
<font color="red"> <b> * </b> </font>

<label Class="Estilo2">Telefono
<input type="text" name="textfield3" tabindex="5" SIZE="12">
</label>
<font color="red"> <b> * </b> </font>



<label class="Estilo2">DNI
<input type="text" name="textfield4" tabindex="6" size="8">
<font color="red"> <b> * </b> </font>
</label>



<label class="Estilo2">Licencia
<input type="text" name="textfield5" tabindex="7" size="1">
<font color="red"> <b> * </b> </font>
</label>

<label Class="Estilo2">Vencimiento
<input type="text" name="textfield6" tabindex="8">
<font color="red"> <b> * </b> </font>
</label>

<label Class="Estilo2">Base
<input type="text" name="textfield7" tabindex="9" Size="3">
<font color="red"> <b> * </b> </font>
</label>

<label Class="Estilo2">Patente
<input type="text" name="textfield8" tabindex="10" size="5">
<font color="red"> <b> * </b> </font>
</label>

<label class="Estilo2">Marca/Modelo
<input type="text" name="textfield9" tabindex="11" size="10">
<font color="red"> <b> * </b> </font>
</label>


<label Class="Estilo2">Color
<input type="text" name="textfield10" tabindex="12" size="3">
</label>
<p>&nbsp;</p>
</form>
</div>

</body>
</html>

Última edición por charlyalize; 13/02/2014 a las 18:00 Razón: Notificacion por correo
  #2 (permalink)  
Antiguo 13/02/2014, 23:14
Avatar de Alexis88
Philosopher
 
Fecha de Ingreso: noviembre-2011
Ubicación: Tacna, Perú
Mensajes: 5.552
Antigüedad: 12 años, 5 meses
Puntos: 977
Respuesta: manejo del teclado con jquey

Los eventos con las teclas funcionan igual en un elemento <select> que en un <input>:

Código Javascript:
Ver original
  1. $("select").keydown(function(e){
  2.     var tecla = e.keyCode || e.which;
  3.  
  4.     if (tecla == 13)
  5.         alert("Hola");
  6.  
  7.     if (tecla == 27)
  8.         alert("Mundo");
  9. });

Sabiendo esto, solamente te queda adaptarlo a tus necesidades, saludos.
__________________
«Juro por mi vida y mi amor por ella, que jamás viviré para el provecho de otro hombre, ni le pediré a otro hombre que viva para el mío».

Ayn Rand
  #3 (permalink)  
Antiguo 13/02/2014, 23:31
 
Fecha de Ingreso: marzo-2009
Mensajes: 32
Antigüedad: 15 años
Puntos: 3
Exclamación Respuesta: manejo del teclado con jquey

Mil GRACIAS "Alexis88", INVALORABLE EL APORTE¡¡¡

SALUDOS¡¡¡

Etiquetas: manejo, teclado
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 22:16.