Implementing shortcut keys in a webpage

前端 未结 7 2178
有刺的猬
有刺的猬 2021-02-08 04:26

I was thinking of implementing shortcut keys in a pet web application, I am developing for me. I am using c# and asp.net.

I have seen very few web-sites( frankly I reme

7条回答
  •  失恋的感觉
    2021-02-08 05:00

    use this javascript on your master page this work using keycode.........
    
    
    ------------------------------------------ 
    
    var isfocused=false;    
       document.onkeydown = overrideKeyboardEvent;
    document.onkeyup = overrideKeyboardEvent;
    var keyIsDown = {};
    var get_focused="";
    function overrideKeyboardEvent(e){
      switch(e.type){
        case "keydown":
          if(!keyIsDown[e.keyCode]){
            keyIsDown[e.keyCode] = true;
            // do key down stuff here
           if (e.keyCode == 40) {
                    var t = new Array;
                    t = document.getElementsByTagName("input");
                    var n = "1";
                    for (var r = 0; r < t.length; r++) {
                        if (t[r].type == "checkbox") {
                            var i = document.cookie.split(";");
                            var s = y = i[0].substr(i[0].indexOf("=") + 1);
                            if (s.toLowerCase().indexOf("active") != -1) {
                                if (n == "2") {
                                    document.getElementById(t[r].id).focus();
                                    document.cookie = "aa" + "=" + t[r].id;
                                    return false
                                }
                                if (t[r].id == s) {
                                    n = "2"
                                }
                            } else {
                                document.getElementById(t[r].id).focus();
                                document.cookie = "aa" + "=" + t[r].id;
                                return false
                            }
                        }
                    }
                }
             if( e.keyCode==115)
            {    e.preventDefault();
                 var c = new Array();
                 c = document.getElementsByTagName('input');
                 for (var i=0;i

提交回复
热议问题