• <bdo id='BT8hV'></bdo><ul id='BT8hV'></ul>
  • <small id='BT8hV'></small><noframes id='BT8hV'>

    <tfoot id='BT8hV'></tfoot>

  • <legend id='BT8hV'><style id='BT8hV'><dir id='BT8hV'><q id='BT8hV'></q></dir></style></legend>

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

        在 Java 中检测和操作键盘方向键

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

          <tfoot id='AH0Tw'></tfoot>
          1. <legend id='AH0Tw'><style id='AH0Tw'><dir id='AH0Tw'><q id='AH0Tw'></q></dir></style></legend>

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

                    <tbody id='AH0Tw'></tbody>
                  本文介绍了在 Java 中检测和操作键盘方向键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  万事如意,

                  我有一个控制台项目,旨在让用户按下键盘方向键(非数字键盘)来移动头像.我很难编码来检查这些键的按下情况.在 Pascal 中,使用readkey"和代码很容易,例如,#80 用于向下按键.然而,我很难理解如何在 Java 中实现相同的功能,尽管我认为我了解 System.in 和 BufferedInputStream 的使用.

                  I have a console project where it is intended the user presses the keyboard direction keys (non-numeric keypad) to move an avatar. I am having difficulty coding to check for the press of these keys. In Pascal it was easy enough to use "readkey" and code, for example, for #80 for the down keypress. However, I am stumped how to implement the same functionality in Java, though I think I understand the use of System.in and BufferedInputStream.

                  谁能帮帮我?非常感谢您的想法或提示.

                  Could anyone help me out? Your thoughts or hints are much appreciated.

                  推荐答案

                  Java 中的控制台支持问题众所周知,我不确定这是否可行.

                  The Console support issue in Java is well known, I am not sure that this is doable.

                  这在 System.in 最初是不可能的,因为它曾经是基于行的.

                  This was not initially possible with System.in since it used to work line-based.

                  Sun 最终添加了一个 java.io.Console 类.

                  Sun eventually added a java.io.Console class.

                  这里是它的 JavaDocs:http://java.sun.com/javase/6/docs/api/java/io/Console.html

                  Here are its JavaDocs: http://java.sun.com/javase/6/docs/api/java/io/Console.html

                  一旦你得到控制台(我认为是从 System.console 获得的),你就可以得到一个阅读器,也许可以从中读取字符,但我不确定它是否包含键.

                  Once you get the console (I think from System.console), you can get a reader and perhaps read characters from it, but I'm not sure if it includes keys.

                  一般来说,如果你想使用键盘,你应该使用 Swing 或 AWT,这很愚蠢.

                  Generally, you're supposed to use Swing or AWT if you want access to the keyboard, which is silly.

                  截至 2007 年,有一个关于它的功能请求:这里

                  As of 2007, there was a feature request about it: here

                  这篇关于在 Java 中检测和操作键盘方向键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何以编程方式生成按键事件? 下一篇:我的布局键盘上的空格按钮大小不会调整大小

                  相关文章

                  最新文章

                • <small id='zmflM'></small><noframes id='zmflM'>

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

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

                      <tfoot id='zmflM'></tfoot>