<tfoot id='vjpXt'></tfoot>

  • <i id='vjpXt'><tr id='vjpXt'><dt id='vjpXt'><q id='vjpXt'><span id='vjpXt'><b id='vjpXt'><form id='vjpXt'><ins id='vjpXt'></ins><ul id='vjpXt'></ul><sub id='vjpXt'></sub></form><legend id='vjpXt'></legend><bdo id='vjpXt'><pre id='vjpXt'><center id='vjpXt'></center></pre></bdo></b><th id='vjpXt'></th></span></q></dt></tr></i><div id='vjpXt'><tfoot id='vjpXt'></tfoot><dl id='vjpXt'><fieldset id='vjpXt'></fieldset></dl></div>

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

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

        检查一个键是否已关闭?

        时间:2023-09-07

                <tbody id='j0VdA'></tbody>
            • <legend id='j0VdA'><style id='j0VdA'><dir id='j0VdA'><q id='j0VdA'></q></dir></style></legend>

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

              • <bdo id='j0VdA'></bdo><ul id='j0VdA'></ul>
                <tfoot id='j0VdA'></tfoot>
                <i id='j0VdA'><tr id='j0VdA'><dt id='j0VdA'><q id='j0VdA'><span id='j0VdA'><b id='j0VdA'><form id='j0VdA'><ins id='j0VdA'></ins><ul id='j0VdA'></ul><sub id='j0VdA'></sub></form><legend id='j0VdA'></legend><bdo id='j0VdA'><pre id='j0VdA'><center id='j0VdA'></center></pre></bdo></b><th id='j0VdA'></th></span></q></dt></tr></i><div id='j0VdA'><tfoot id='j0VdA'></tfoot><dl id='j0VdA'><fieldset id='j0VdA'></fieldset></dl></div>

                  本文介绍了检查一个键是否已关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  有没有办法检测一个键当前是否在 JavaScript 中被关闭?

                  Is there a way to detect if a key is currently down in JavaScript?

                  我知道keydown"事件,但这不是我需要的.按键被按下后的一段时间,我希望能够检测它是否仍然被按下.

                  I know about the "keydown" event, but that's not what I need. Some time AFTER the key is pressed, I want to be able to detect if it is still pressed down.

                  P.S. 最大的问题似乎是在一段时间后键开始重复,像恶魔一样触发 keydown 和 keyup 事件.希望只有一个简单的 isKeyDown(key) 函数,但如果没有,则需要克服/解决这个问题.

                  P. S. The biggest issue seems to be that after some period of time the key begins to repeat, firing off keydown and keyup events like a fiend. Hopefully there is just a simple isKeyDown(key) function, but if not then this issue will need to be overcome / worked around.

                  推荐答案

                  有没有办法检测一个键当前是否在 JavaScript 中被关闭?

                  Is there a way to detect if a key is currently down in JavaScript?

                  不.唯一的可能是监控每个 keyupkeydown 并记住.

                  Nope. The only possibility is monitoring each keyup and keydown and remembering.

                  一段时间后,按键开始重复,像恶魔一样触发 keydown 和 keyup 事件.

                  after some period of time the key begins to repeat, firing off keydown and keyup events like a fiend.

                  不应该.你肯定会得到 keypress 重复,并且在许多浏览器中你也会得到重复 keydown,但是如果 keyup 重复,这是一个错误.

                  It shouldn't. You'll definitely get keypress repeating, and in many browsers you'll also get repeated keydown, but if keyup repeats, it's a bug.

                  不幸的是,这不是一个完全闻所未闻的错误:在 Linux、Chromium 和 Firefox 上(当它在 GTK+ 下运行时,它在流行的发行版中,如 Ubuntu)都生成重复的 keyup-keypress-keydown 序列握着钥匙,这与快速敲击钥匙的人无法区分.

                  Unfortunately it is not a completely unheard-of bug: on Linux, Chromium, and Firefox (when it is being run under GTK+, which it is in popular distros such as Ubuntu) both generate repeating keyup-keypress-keydown sequences for held keys, which are impossible to distinguish from someone hammering the key really fast.

                  这篇关于检查一个键是否已关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:keypress 和 keyup - 为什么 keyCode 不同? 下一篇:为什么在 keydown 回调中返回 false 不会停止按钮单

                  相关文章

                  最新文章

                  • <bdo id='WsAjA'></bdo><ul id='WsAjA'></ul>

                    <legend id='WsAjA'><style id='WsAjA'><dir id='WsAjA'><q id='WsAjA'></q></dir></style></legend>
                  1. <i id='WsAjA'><tr id='WsAjA'><dt id='WsAjA'><q id='WsAjA'><span id='WsAjA'><b id='WsAjA'><form id='WsAjA'><ins id='WsAjA'></ins><ul id='WsAjA'></ul><sub id='WsAjA'></sub></form><legend id='WsAjA'></legend><bdo id='WsAjA'><pre id='WsAjA'><center id='WsAjA'></center></pre></bdo></b><th id='WsAjA'></th></span></q></dt></tr></i><div id='WsAjA'><tfoot id='WsAjA'></tfoot><dl id='WsAjA'><fieldset id='WsAjA'></fieldset></dl></div>
                  2. <small id='WsAjA'></small><noframes id='WsAjA'>

                    <tfoot id='WsAjA'></tfoot>