简体   繁体   English

以后如何减小虚拟钥匙?

[英]How to make virtual key small later?

How to make small vk letters like case VK_k instead of VK_K? 如何制作小写的vk字母,例如大小写VK_k而不是VK_K? using Switch Case Thanks 使用开关盒谢谢

public void onKeyPressed(KeyEvent e){

    switch(e.getKeyCode()){

    case VK_K: 
               moveDirection=1;
               moveAmount = Double.POSITIVE_INFINITY;

             break;

    case VK_L: moveDirection=-1;
               moveAmount = Double.POSITIVE_INFINITY;
             break;

    case VK_H: turnDirection=-1;
             break;

    case VK_J: turnDirection=1;
             break;
    case VK_SPACE: firePower = 1;
            break;

    }

}

You should read the description of KeyEvent fully - it contains the answer: 您应该完整阅读KeyEvent的描述-包含答案:

Virtual key codes are used to report which keyboard key has been pressed, rather than a character generated by the combination of one or more keystrokes (such as "A", which comes from shift and "a"). 虚拟键码用于报告已按下哪个键盘键,而不是由一个或多个键击组合产生的字符(如“ A”,它来自shift和“ a”)。

Conclusion: Your keyboard has only one K key - hence there is only the constant VK_K . 结论:您的键盘只有一个K键-因此只有常数VK_K What other keys (shift, alt, ctrl, ..) you are pressing at the same time does not change the key code you get. 同时按下的其他键(Shift,Alt,Ctrl,..)不会更改您获得的键代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM