📜  HTML5 Accesskey 属性:您可能不需要 JavaScript 来添加键盘快捷键 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:41.509000             🧑  作者: Mango

代码示例1
// Register the key handler 
document.addEventListener('keyup', function(e){
    // This would be triggered by pressing CTRL + A
    if (e.ctrlKey && e.keyCode == 65) {
        window.location.href = "http://ourcodeworld.com"; 
    }

    // Or with ALT + A
    //if (e.altKey && e.keyCode == 65) {
    //    window.location.href = "http://ourcodeworld.com"; 
    //}
}, false);