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

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

        <legend id='VyRAV'><style id='VyRAV'><dir id='VyRAV'><q id='VyRAV'></q></dir></style></legend>

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

          <bdo id='VyRAV'></bdo><ul id='VyRAV'></ul>

        在按键上检测 Alt Gr(Alt Graph)修饰符

        时间:2023-09-07
              <tbody id='PTghj'></tbody>
            • <bdo id='PTghj'></bdo><ul id='PTghj'></ul>

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

                <tfoot id='PTghj'></tfoot>
                • <legend id='PTghj'><style id='PTghj'><dir id='PTghj'><q id='PTghj'></q></dir></style></legend>
                  <i id='PTghj'><tr id='PTghj'><dt id='PTghj'><q id='PTghj'><span id='PTghj'><b id='PTghj'><form id='PTghj'><ins id='PTghj'></ins><ul id='PTghj'></ul><sub id='PTghj'></sub></form><legend id='PTghj'></legend><bdo id='PTghj'><pre id='PTghj'><center id='PTghj'></center></pre></bdo></b><th id='PTghj'></th></span></q></dt></tr></i><div id='PTghj'><tfoot id='PTghj'></tfoot><dl id='PTghj'><fieldset id='PTghj'></fieldset></dl></div>
                  本文介绍了在按键上检测 Alt Gr(Alt Graph)修饰符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  在 javascript Event 对象中,有一些布尔值来检查是否按下了修饰键:

                  In the javascript Event object, there are some boolean values to check if modifier keys are pressed:

                  • ctrlKey:CTRL键.
                  • altKey:ALT键.
                  • altLeft:ALT 左键.仅适用于 IE.
                  • altGraphKey:ALTGR 键.仅适用于 Chrome/Safari.
                  • ctrlKey: CTRL key.
                  • altKey: ALT key.
                  • altLeft: ALT left key. Only for IE.
                  • altGraphKey: ALTGR key. Only for Chrome/Safari.

                  但是,有一些问题:

                  • 当您按下 ALTGR 修饰符时,IE 和 Chrome 将 ctrlKey 设置为 true 并将 altKey 设置为 true.
                  • 当您按下 ALTGR 修饰符时,Firefox 将 ctrlKey 设置为 false 并将 altKey 设置为 true,因为只有 ALT已按下.
                  • Chrome 有 altGraphKey 属性,但它始终是 undefined.
                  • IE and Chrome set ctrlKey to true and altKey to true when you press the ALTGR modifier.
                  • Firefox sets ctrlKey to false and altKey to true when you press the ALTGR modifier, as only ALT has been pressed.
                  • Chrome has the altGraphKey property, but it is always undefined.

                  问题:如何区分 ALT+CTRLALTGR 按键?特别是在 Chrome 中.

                  Question: how can I difference between an ALT+CTRL or an ALTGR key press? Specially in Chrome.

                  推荐答案

                  webkit 浏览器中的 altGraphKey 似乎不再存在(截至 2013 年 9 月),并且 Firefox 的行为发生了变化.AltGr 键的浏览器行为当前似乎是:

                  The altGraphKey in webkit browsers no longer appears to exist (as at September 2013) and the behaviour of Firefox has changed. Browser behaviours for the AltGr key currently appear to be:

                  • Webkit (Chrome) - ctrlKey: true, altKey: true
                  • IE 8 - ctrlKey: false, altKey: true
                  • IE 10 - ctrlKey: true, altKey: true
                  • Mozilla (Firefox) - ctrlKey: true, altKey: true

                  也就是说,它们当前都是一致的(除了 IE8,它仍然始终不一致).

                  Which is to say, they are all currently consistent (apart from IE8, which remains consistently inconsistent).

                  以下代码段应该在现代浏览器中捕获 Alt Gr - 但不是 AltCtrl -.但是,您将需要 IE8 的特殊情况:

                  The following snippet should catch Alt Gr - but not Alt or Ctrl - in modern browsers. You will need a special case for IE8 however:

                  if (event.ctrlKey && event.altKey) {
                      // Appears to be Alt Gr
                  }
                  

                  这篇关于在按键上检测 Alt Gr(Alt Graph)修饰符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:为 HTML 输入设置默认语言 下一篇:如何捕获触摸设备的屏幕键盘“keydown"和“

                  相关文章

                  最新文章

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

                    <bdo id='f4HsX'></bdo><ul id='f4HsX'></ul>

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

                      <legend id='f4HsX'><style id='f4HsX'><dir id='f4HsX'><q id='f4HsX'></q></dir></style></legend>

                      <tfoot id='f4HsX'></tfoot>