久久久久久久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>
                          • 主站蜘蛛池模板: 在线a视频网站 | 日韩视频成人 | 欧美日韩一区二区电影 | 亚洲综合视频 | 日韩欧美一级片 | 中文字幕乱码一区二区三区 | 国产福利在线 | 激情欧美日韩一区二区 | 欧美日韩国产一区二区三区不卡 | 狠狠爱免费视频 | 久久精品国产亚洲一区二区三区 | 久久久精品视频免费 | 99福利视频| 久久尤物免费一区二区三区 | 成人精品鲁一区一区二区 | 亚洲va欧美va天堂v国产综合 | 国产麻豆乱码精品一区二区三区 | 懂色中文一区二区在线播放 | 欧美成人a∨高清免费观看 色999日韩 | 亚洲综合色视频在线观看 | 97精品国产97久久久久久免费 | 成人三区四区 | 国产一区二区精品在线观看 | 国产精品日韩欧美一区二区三区 | 成在线人视频免费视频 | 成人性视频免费网站 | 在线国产一区 | 一区二区不卡视频 | 久草99 | 精品视频在线观看 | 久久国产精品-国产精品 | 日日摸夜夜添夜夜添特色大片 | 亚洲久久一区 | 亚洲国产成人在线观看 | 九色www| 国产九九av | 国产日韩91| 91视频国产精品 | 国产在线观看一区二区 | 天天草草草| av色在线 |