JAVA tank battle project practice day 4

1. getKeyCode () for keyboard events in java

getKeyCode () Each button on the keyboard has a corresponding code (Code), which can be used to find out what key the user pressed, such as [Shift] key code 16. This code can be known using the getKeyCode () method, but readers should note that this method cannot be detected on keyTyped (), because keyTyped () only controls the characters entered by the user, not the corresponding code on the keyboard. Therefore, you must write the getKeyCode () method in the keyPressed () or keyReleased () method to be effective, because these two methods are relatively low-level methods.

2. Keys that control up, down, left, and right in KeyEvent VK_UP VK_DOWN VK_LEFT VK_RIGHT

 

Guess you like

Origin www.cnblogs.com/de-ming/p/12690408.html