• 02-05-2010, 00:21:13
    #1
    Merhaba,

    Klavyeden herhangi bir tuşa basıldığında, hangi tuşa basıldıysa ona göre başka bir sayfaya yönlendirmek istiyoruz. javascript ile halledilebilir diye düşünüyorum ama aramalarım sonucunda bir bilgiye ulaşamadık.

    Bu konuda bilgisi olan arkadaş varsa yardım edebilirse sevinirim.

    İyi çalışmalar...
  • 02-05-2010, 01:12:07
    #2
    Basitçe şöyle bir kodla halledebilirsiniz.

     function displayKeyCode(evt)
     {
    	var textBox = getObject('txtChar');
    	 var charCode = (evt.which) ? evt.which : event.keyCode
    	 textBox.value = String.fromCharCode(charCode);
    	 if (charCode == 8) window.location="http://www.siteadresi.com";
     //  backspace
    	 if (charCode == 9) window.location="http://www.siteadresi.com";
     //  tab
    	 if (charCode == 13) window.location="http://www.siteadresi.com";
     //  enter
    	 if (charCode == 16) textBox.value =window.location="http://www.siteadresi.com";
     //  shift
    
    	 var lblCharCode = getObject('spnCode');
    	lblCharCode.innerHTML = 'KeyCode:  ' + charCode;
    
    	return false;
    
     }
     function getObject(obj)
      {
    	  var theObj;
    	  if (document.all) {
    		  if (typeof obj=='string') {
    			  return document.all(obj);
    		  } else {
    			  return obj.style;
    		  }
    	  }
    	  if (document.getElementById) {
    		  if (typeof obj=='string') {
    			  return document.getElementById(obj);
    		  } else {
    			  return obj.style;
    		  }
    	  }
    	  return null;
      }
     //-->
    Daha detaylı bilgi ve tuşların karakter karşılığına http://www.cambiaresearch.com/c4/702...Key-Codes.aspx burdaki örnekten bakarsın