JS代码
<html> <head> <スクリプトタイプ= "text/javascript"> window.onload = function(){hotkeyhandler.init(); } var hotkeyhandler = {currentMainkey:null、currentValueKey:null、init:function(){hotkeyhandler.register(0、 "k"、function(){alert( "注册成功");}); }、登録:function(tag、value、func){var mainkey = ""; switch(tag){case 0:mainkey = 17; // ctrl break;ケース1:MainKey = 16; // Shift Break;ケース2:mainkey = "18"; // alt break; } document.onkeyup = function(e){hotkeyhandler.currentmainkey = null; } document.onkeydown = function(event){// var keyvalue = string.fromcharcode(event.keycode); if(hotkeyhandler.currentmainkey!= null){if(keyvalue == value){hotkeyhandler.currentmainkey = null; if(func!= null)func(); }} if(keycode == mainkey)hotkeyhandler.currentmainkey = keycode; }}} </script> </head> <body>测试、按下ctrl+k你就会发现神奇的事情发生了</body> </html>