2013-10-25 33 views
2

我有一段時間沒有使用過jquery.hotkeys.js,但我似乎甚至無法在任何當前瀏覽器中使用最基本的測試。jquery熱鍵無法在當前瀏覽器中工作?

使用Ver 0.8我也嘗試過其他版本的jQuery,但是堅持使用1.4.2進行測試,因爲那是John Resig在他的例子中所做的。

<html> 
<head> 
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
    <script src="/js/jquery.hotkeys.js"></script> 
    <script> 
     jQuery(document).ready(function(){    
      $(document).bind('keydown', "f", function() { 
       alert("click"); 
       return false; 
      });  
     });  
    </script> 
</head> 
<body> 

+1

按照問題這裏 - http://stackoverflow.com/questions/18907673/latest-version-of-jquery-hotkeys-plugin-doesnt-accept-characters-unless-using-k on 「按鍵」事件起作用。 – Alex

回答

1

我不知道綁定方面,但是這似乎爲我

 $(document).keydown(function (event) { 
     if (event.ctrlKey && event.keyCode == 90) { 
      alert('hi, you just pressed ctrl-z'); 
     } 
    }); 

完整的代碼在這裏工作:

<html> 
<head> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
    <script> 
     $(document).ready(function() { alert('1st'); }); 
     $(document).keydown(function (event) { 
      if (event.ctrlKey && event.keyCode == 90) { 
        alert('hi, you just pressed ctrl-z'); 
      } 
     }); 

    </script> 
</head> 
<body> 
相關問題