7月 19, 2015

按按鍵執行跳轉

  window.onkeyup = hr;
        var keyCount = 0;
        function hr(e) {
            if (e.keyCode === 72 && keyCount === 0) {
                keyCount++;
            } else if (e.keyCode === 82 && keyCount === 1) {
                alert('進入特殊模式!');
                window.location = "/ang.aspx";
                keyCount = 0;
            } else {
                keyCount = 0;
            };
        };
        function konami(e) {
            if (e.keyCode === 38 && keyCount === 0) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 38 && keyCount === 1) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 40 && keyCount === 2) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 40 && keyCount === 3) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 37 && keyCount === 4) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 39 && keyCount === 5) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 37 && keyCount === 6) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 39 && keyCount === 7) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 66 && keyCount === 8) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 65 && keyCount === 9) {            
                alert('進入特殊模式!');
                window.location = "/ang.aspx";
                keyCount = 0;
            } else {
                keyCount = 0;
                
            }
        }
        

沒有留言: