JS 代码
<html> <éad- head> <script type = "text / javascript"> window.onload = function () {hotkeyhandler.init (); } var hotkeyhandler = {currentMainkey: null, currentValueKey: null, init: function () {hotkeyhandler.register (0, "k", function () {alert ("注册成功");}); }, Registre: function (tag, valeur, func) {var MainKey = ""; switch (tag) {case 0: MainKey = 17; // ctrl pause; Cas 1: Mainkey = 16; // Shift Break; Cas 2: Mainkey = "18"; // alt pause; } document.onKeyUp = function (e) {hotkeyhandler.currentMainKey = null; } document.onkeydown = function (event) {// 获取键值 var keycode = event.KeyCode; var keyvalue = string.fromCharcode (event.KeyCode); if (hotkyhandler.currentMainKey! = null) {if (keyValue == Value) {hotkeyhandler.currentmainkey = null; if (func! = null) func (); }} if (keycode == mainkey) hotkeyhandler.currentMainkey = keycode; }}} </ script> </ head> <body> 测试 , 按下 ctrl + k 你就会发现神奇的事情发生了 </ody> </html>