Ver Mensaje Individual
  #6 (permalink)  
Antiguo 22/09/2010, 08:49
Avatar de neodani
neodani
 
Fecha de Ingreso: marzo-2007
Mensajes: 1.811
Antigüedad: 17 años, 1 mes
Puntos: 20
Respuesta: Realizar acción si se pulsa una tecla especifica

Cita:
Iniciado por Dany_s Ver Mensaje
bueno tenes que comprobar si tiene pulsada el ctrl o el alt

para el ctrl = e.ctrlKey que devuelve un booleano
para el alt = e.altKey también un booleano

Código HTML:
Ver original
  1. $( function (){
  2.             $(document).keydown(function(e){
  3.                 if (e.ctrlKey){
  4.                     alert("control");
  5.                 }
  6.                 if (e.altKey){
  7.                     alert("alt");
  8.                 }
  9.             });
  10.         });


o usa este plugin http://plugins.jquery.com/project/hotkeys
El problema al cual me refería lo solucioné así, comentando esas lineas :)

Código Javascript:
Ver original
  1. $(document).ready(function(){
  2.    $("html").keypress(function(e){
  3.       //e.preventDefault();
  4.       //$("#tecla-pulsada").html(e.which + ": " + String.fromCharCode(e.which))
  5.       if (String.fromCharCode(e.which)=='m'){
  6.         $("#mostrar").show("slow");
  7.       }else{
  8.         $("#mostrar").hide("slow")
  9.       }
  10.    });
  11. })