【发布时间】:2011-08-17 12:26:30
【问题描述】:
要求是,在屏幕中我们需要有“ctrl+1, Ctrl+2 & ctrl+3”的热键。使用热键插件 [http://code.google.com/p/js-hotkeys/],如果我在浏览器中打开下面的页面并且按 'ctrl+1,我会遇到以下代码的一些问题' 警报消息出现两次,预期结果是我们应该只得到“你找到了热键 ctrl+1!”警觉一次。我是 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>
谢谢, ~公羊
【问题讨论】:
标签: jquery-plugins