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

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

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

      1. 如何在 Java 中处理同时按键?

        时间:2023-09-27
        <i id='M6GcS'><tr id='M6GcS'><dt id='M6GcS'><q id='M6GcS'><span id='M6GcS'><b id='M6GcS'><form id='M6GcS'><ins id='M6GcS'></ins><ul id='M6GcS'></ul><sub id='M6GcS'></sub></form><legend id='M6GcS'></legend><bdo id='M6GcS'><pre id='M6GcS'><center id='M6GcS'></center></pre></bdo></b><th id='M6GcS'></th></span></q></dt></tr></i><div id='M6GcS'><tfoot id='M6GcS'></tfoot><dl id='M6GcS'><fieldset id='M6GcS'></fieldset></dl></div>

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

      2. <legend id='M6GcS'><style id='M6GcS'><dir id='M6GcS'><q id='M6GcS'></q></dir></style></legend>
          • <bdo id='M6GcS'></bdo><ul id='M6GcS'></ul>

                <tbody id='M6GcS'></tbody>

                  <tfoot id='M6GcS'></tfoot>
                  本文介绍了如何在 Java 中处理同时按键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  如何在 Java 中处理同时按下的按键?

                  How do I handle simultaneous key presses in Java?

                  我正在尝试编写游戏,需要同时处理多个按键.

                  I'm trying to write a game and need to handle multiple keys presses at once.

                  当我按住一个键(例如向前移动)然后按住另一个键(例如向左转)时,会检测到新键,但不再检测到旧按键.

                  When I'm holding a key (let's say to move forward) and then I hold another key (for example, to turn left), the new key is detected but the old pressed key isn't being detected anymore.

                  推荐答案

                  一种方法是跟踪自己当前关闭的键.

                  One way would be to keep track yourself of what keys are currently down.

                  当你得到一个 keyPressed 事件时,将新的键添加到列表中;当您收到 keyReleased 事件时,从列表中删除该键.

                  When you get a keyPressed event, add the new key to the list; when you get a keyReleased event, remove the key from the list.

                  然后在您的游戏循环中,您可以根据键列表中的内容执行操作.

                  Then in your game loop, you can do actions based on what's in the list of keys.

                  这篇关于如何在 Java 中处理同时按键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:检测到的 JDK 版本:1.6.0-24 不在允许的 1.7 范围内 下一篇:Java 从 MIDI 键盘获取输入

                  相关文章

                  最新文章

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

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

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