久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <tfoot id='xcJcZ'></tfoot>

      • <bdo id='xcJcZ'></bdo><ul id='xcJcZ'></ul>
      <legend id='xcJcZ'><style id='xcJcZ'><dir id='xcJcZ'><q id='xcJcZ'></q></dir></style></legend>

    1. <i id='xcJcZ'><tr id='xcJcZ'><dt id='xcJcZ'><q id='xcJcZ'><span id='xcJcZ'><b id='xcJcZ'><form id='xcJcZ'><ins id='xcJcZ'></ins><ul id='xcJcZ'></ul><sub id='xcJcZ'></sub></form><legend id='xcJcZ'></legend><bdo id='xcJcZ'><pre id='xcJcZ'><center id='xcJcZ'></center></pre></bdo></b><th id='xcJcZ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='xcJcZ'><tfoot id='xcJcZ'></tfoot><dl id='xcJcZ'><fieldset id='xcJcZ'></fieldset></dl></div>

    2. <small id='xcJcZ'></small><noframes id='xcJcZ'>

        如何避免 JavaScript 中自動重復的 keydown 事件?

        How can I avoid autorepeated keydown events in JavaScript?(如何避免 JavaScript 中自動重復的 keydown 事件?)

        <small id='gxdkb'></small><noframes id='gxdkb'>

      1. <tfoot id='gxdkb'></tfoot>

                <legend id='gxdkb'><style id='gxdkb'><dir id='gxdkb'><q id='gxdkb'></q></dir></style></legend>
                  <tbody id='gxdkb'></tbody>
                  <bdo id='gxdkb'></bdo><ul id='gxdkb'></ul>
                  <i id='gxdkb'><tr id='gxdkb'><dt id='gxdkb'><q id='gxdkb'><span id='gxdkb'><b id='gxdkb'><form id='gxdkb'><ins id='gxdkb'></ins><ul id='gxdkb'></ul><sub id='gxdkb'></sub></form><legend id='gxdkb'></legend><bdo id='gxdkb'><pre id='gxdkb'><center id='gxdkb'></center></pre></bdo></b><th id='gxdkb'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='gxdkb'><tfoot id='gxdkb'></tfoot><dl id='gxdkb'><fieldset id='gxdkb'></fieldset></dl></div>

                  本文介紹了如何避免 JavaScript 中自動重復的 keydown 事件?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  如果用戶按住鍵,則會觸發多個 keydown 事件.出于可用性原因,我需要使用 keydown,而不是 keyup,但我想避免這種情況.我的相關代碼如下:

                  If the user holds down the key, multiple keydown events are fired. For usability reasons I need to use keydown, not keyup, but I want to avoid this situation. My relevant code is the following:

                  $(document).keydown(function(e) { 
                          var key = 0;
                  
                  
                          if (e == null) { key = event.keyCode;}  
                          else {  key = e.which;} 
                  
                  
                          switch(key) {
                              case config.keys.left:                
                                goLeft();
                                break;
                              case config.keys.up:                        
                                goUp();
                                break;
                              case config.keys.right:                     
                                goRight();
                                break;
                              case config.keys.down:                
                                goDown();
                                break;
                              case config.keys.action:              
                                select();
                                break;
                          }     
                        });
                  

                  因此,例如,當用戶按住向下鍵時,會多次觸發 goDown().即使用戶按住鍵,我也希望它只觸發一次.

                  So when the user holds down the down key, for example, goDown() is fired multiple times. I would like it to fire just once even if the user holds the key down.

                  推薦答案

                  使用 event.repeat 檢測事件是否重復.然后,您可以在允許處理程序第二次執行之前等待keyup".

                  Use event.repeat to detect whether or not the event is repeating. You could then wait for "keyup" before allowing the handler to execute a second time.

                  var allowed = true;
                  
                  $(document).keydown(function(event) { 
                    if (event.repeat != undefined) {
                      allowed = !event.repeat;
                    }
                    if (!allowed) return;
                    allowed = false;
                    //...
                  });
                  
                  $(document).keyup(function(e) { 
                    allowed = true;
                  });
                  $(document).focus(function(e) { 
                    allowed = true;
                  });
                  

                  這篇關于如何避免 JavaScript 中自動重復的 keydown 事件?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數據更新 Observable)
                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態元素 - Angular 2 amp;離子2)

                • <small id='19OlN'></small><noframes id='19OlN'>

                  <tfoot id='19OlN'></tfoot>
                    <tbody id='19OlN'></tbody>

                  • <legend id='19OlN'><style id='19OlN'><dir id='19OlN'><q id='19OlN'></q></dir></style></legend>
                      <i id='19OlN'><tr id='19OlN'><dt id='19OlN'><q id='19OlN'><span id='19OlN'><b id='19OlN'><form id='19OlN'><ins id='19OlN'></ins><ul id='19OlN'></ul><sub id='19OlN'></sub></form><legend id='19OlN'></legend><bdo id='19OlN'><pre id='19OlN'><center id='19OlN'></center></pre></bdo></b><th id='19OlN'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='19OlN'><tfoot id='19OlN'></tfoot><dl id='19OlN'><fieldset id='19OlN'></fieldset></dl></div>

                            <bdo id='19OlN'></bdo><ul id='19OlN'></ul>
                          • 主站蜘蛛池模板: 亚洲免费三级 | 色综合桃花网 | 免费视频一区二区三区在线观看 | 国产98色在线 | 日韩 | 狠狠色综合久久婷婷 | 欧美精品综合 | 欧美黄色一区 | 国产精品日韩欧美一区二区三区 | 国产精品视频一二三区 | 国产成人精品在线 | 国产欧美日韩一区二区三区在线观看 | 亚洲国产一区二区在线 | 国产精品污www一区二区三区 | 免费麻豆视频 | 美女爽到呻吟久久久久 | 二区精品 | 国内精品视频一区二区三区 | 国产精品美女久久久久久久久久久 | 影音先锋中文在线 | 日批日韩在线观看 | 免费亚洲视频 | 亚洲视频1区 | 日韩久草| 亚洲欧美中文日韩在线v日本 | 伊色综合久久之综合久久 | 久久国产精品久久国产精品 | 在线观看国产www | 日韩欧美在线不卡 | 亚洲综合在线视频 | 懂色av色香蕉一区二区蜜桃 | 国产欧美日韩一区二区三区 | 日韩视频一级 | 国产精品久久国产精品 | 精国产品一区二区三区四季综 | 成人av片在线观看 | 干干天天| 免费的av网站 | 成人国产精品久久 | 国产精品免费一区二区三区四区 | 国产欧美一级 | 久久国产精品免费视频 |