Virtual key codes do not identify a physical key: they depend on the.No attempt is made in Java to generate these keys Not all keyboards or systems are capable of generating all.Keys like F1 and the HELP key, do not generate KEY_TYPED events. Key combinations which do not result in Unicode characters, such as action.auto-repeat or input method is activated) the orderĬould be different (and platform dependent). KEY_PRESSED KEY_TYPED (is only generated if a valid Unicode character could be generated.)īut in some cases (e.g. Pressing and releasing a key on the keyboard results in the generating Separately, a KEY_TYPED event with a ke圜har After the 'a' key is released, a KEY_RELEASED event With a VK_SHIFT ke圜ode, while pressing the 'a' key will result inĪ VK_A ke圜ode. Of one or more keystrokes (such as "A", which comes from shift and "a").įor example, pressing the Shift key will cause a KEY_PRESSED event Virtual key codes are used to report which keyboard key hasīeen pressed, rather than a character generated by the combination Methods, which return a virtual key code. The keyīeing pressed or released is indicated by the getKe圜ode and getExtendedKe圜ode Generate character input (e.g., action keys, modifier keys, etc.). Pressed or released, and are the only way to find out about keys that don't
"Key pressed" and "key released" events are lower-level and depend May also be used with many international keyboard layouts. For key typed events, the getKe圜ode methodĪlways returns VK_UNDEFINED. Is guaranteed to be meaningful only for KEY_TYPED events.įor key pressed and key released events, the getKe圜ode method returns Therefore, the result of the getKe圜har method KEY_PRESSED and KEY_RELEASED events are not necessarily associated Character input is reported by KEY_TYPED events: The getKe圜har method always returns a valid Unicode character orĬHAR_UNDEFINED. No key typed events are generated for keys that don't generate UnicodeĬharacters (e.g., action keys, modifier keys, etc.).
Where the key typed event is not generated until a key is released (e.g.,Įntering ASCII sequences via the Alt-Numpad method in Windows). Usually necessary to generate a key typed event, but there are some cases Key typed events may be many-to-one or many-to-many. Presses (e.g., 'shift' + 'a'), and the mapping from key pressed events to
Often, however, characters are produced by series of key In the simplest case, a key typed event is produced by a single key press Is entered, and are the preferred way to find out about character input. They are generated when a Unicode character "Key typed" events are higher-level and generally do not depend on
Gets this KeyEvent when the event occurs. KeyListener interface.) Each such listener object Or KeyAdapter object which registered to receive suchĮvents using the component's addKeyListener method. This low-level event is generated by a component object (such as a textįield) when a key is pressed, released, or typed. Note: To use these codes in the VKMapping section, the hexadecimal values need to be converted to decimals.An event which indicates that a keystroke occurred in a component.
The following table shows the symbolic constant names, hexadecimal values, and keyboard equivalents for the virtual-key codes used by Microsoft Windows Mobile 6.0.