(1. There are also two methods in the KeyEvent class that are often used, namely getKeyCode() and getKeyModifiersText(intmodifiers). Each button on the keyboard has a corresponding code (Code), which can be used to find out what key the user has pressed, such as The [Shift] key code is 16. This code can be obtained by using the getKeyCode() method, but the reader should note that this method cannot be detected on keyTyped(), because keyTyped() only cares about the characters entered by the user, but not the corresponding code of the keyboard. It's a way to manage things at a higher level. That is to say, the keyTyped() method is keyboadindependent, because different keyboards may have different corresponding codes (for example, WindowsU.S.keyboard and windowsFrenchkeyboard have different corresponding codes). Therefore, you must write the getKeyCode() method in the keyPressed() or keyReleased() method to be effective, because these two methods are relatively low-level management methods.
JAVA_Proficient in swing programming.chm)