1
要求是,在屏幕上我們需要爲「ctrl + 1,Ctrl + 2 & ctrl + 3」提供熱鍵。使用熱鍵插件[http://code.google.com/p/js-hotkeys/],我在瀏覽器中遇到以下代碼的一些問題,如果我打開下面的頁面,並且按'ctrl + 1 '警報消息來了兩次,因爲預期的結果是我們應該只得到「你找到了熱鍵Ctrl + 1!」警報一次。我是新來的JQuery世界,所以我不知道天氣我錯過了一些事情或插件它自己有一些已知的問題。JQuery - 帶有多個綁定調用的熱鍵
有人可以對此問題發表評論。
<html>
<head>
<title>JQuery Hotkeys</title>
<script src="jquery-1.6.2.min.js"></script>
<script src="jquery.hotkeys-0.7.9.js"></script>
<script>
$(document).bind('keydown', 'ctrl+1', function() {
alert('You found the hotkey ctrl+1!');
});
$(document).bind('keydown', 'ctrl+2', function() {
alert('You found the hotkey ctrl+2!');
});
</script>
</head>
<body>
HOYKEY DEMO : Press 'Ctrl+1/Ctrl+2'
</body>
</html>
感謝, 〜拉姆