使用方法:
- $.hotkeys.add('鍵名', function(){ 要實現的目的});
- //鍵名可以是單鍵,也可以是組合鍵例如:ctrl+c就表示同時按下ctrl和c.
取消某個鍵的事件:
- $.hotkeys.remove('鍵名');
參照文檔也可以這樣使用:
- <script src="jquery-1.4.1.min.js" type="text/javascript"></script>
- <script src="jquery.hotkeys.js" type="text/javascript"></script>
- <script type="text/javascript">
- $(function () {
- $(document).bind("keydown", "esc", function (ev) { alert("您按下了Esc鍵!"); //其它處理事件; return false; })
- .bind("keydown", "1", function (er) { alert("您按下了1鍵!"); return false; })
- .bind("keydown", "2", function (er) { alert("您按下了2鍵!"); return false; })
- .bind("keydown", "3", function (er) { alert("您按下了3鍵!"); return false; })
- .bind("keydown", "4", function (er) { alert("您按下了4鍵!"); return false; })
- });
- </script>
具體演示效果,請查看jQuery HotKeys插件使用
jquery.hotkeys插件下載
jQuery HotKeys演示地址
你可能還感興趣:
Chrome 控制臺新玩法-console顯示圖片以及為文字加樣式
本站歡迎任何形式的轉載,但請務必注明出處,尊重他人勞動成果
轉載請注明: 文章轉載自:愛思資源網 http://www.randomwithlife.com/show-79-821-1.html
轉載請注明: 文章轉載自:愛思資源網 http://www.randomwithlife.com/show-79-821-1.html