JS 代码
<html> <head> <script type = "text/javaScript"> window.onload = function () {hotkeyHandler.init (); } var hotkeyHandler = {currentMainkey: null, currentValuekey: null, init: function () {hotkeyHandler.register (0, "k", function () {alert ("注册成功");}); }, Registrar: function (etiqueta, valor, func) {var justo = ""; switch (etiqueta) {caso 0: justo = 17; // break ctrl; Caso 1: Justo = 16; // Break Break; Caso 2: justo = "18"; // ruptura alt; } document.OnKeyUp = function (e) {hotkeyHandler.currentMainkey = null; } document.onkeydown = function (event) {// 获取键值 var keyCode = event.keycode; var keyValue = String.FromCharCode (event.KeyCode); if (hotkeyHandler.CurrentMainkey! = null) {if (keyValue == value) {hotkeyHandler.CurrentMainkey = null; if (func! = null) func (); }} if (keycode == justo) hotkeyHandler.currentMainkey = keycode; }}} </script> </head> <body> 测试 , 按下 ctrl+k 你就会发现神奇的事情发生了 </body> </html>