Key events are generated when the user types on the keyboard.
public class java.awt.event.KeyEvent extends java.awt.event.InputEvent { // Constants public final static int CHAR_UNDEFINED; public final static int KEY_FIRST; public final static int KEY_LAST; public final static int KEY_PRESSED; public final static int KEY_RELEASED; public final static int KEY_TYPED; public final static int VK_0; public final static int VK_1; public final static int VK_2; public final static int VK_3; public final static int VK_4; public final static int VK_5; public final static int VK_6; public final static int VK_7; public final static int VK_8; public final static int VK_9; public final static int VK_A; public final static int VK_ACCEPT; public final static int VK_ADD; public final static int VK_ALT; public final static int VK_B; public final static int VK_BACK_QUOTE; public final static int VK_BACK_SLASH; public final static int VK_BACK_SPACE; public final static int VK_C; public final static int VK_CANCEL; public final static int VK_CAPS_LOCK; public final static int VK_CLEAR; public final static int VK_CLOSE_BRACKET; public final static int VK_COMMA; public final static int VK_CONTROL; public final static int VK_CONVERT; public final static int VK_D; public final static int VK_DECIMAL; public final static int VK_DELETE; public final static int VK_DIVIDE; public final static int VK_DOWN; public final static int VK_E; public final static int VK_END; public final static int VK_ENTER; public final static int VK_EQUALS; public final static int VK_ESCAPE; public final static int VK_F; public final static int VK_F1; public final static int VK_F2; public final static int VK_F3; public final static int VK_F4; public final static int VK_F5; public final static int VK_F6; public final static int VK_F7; public final static int VK_F8; public final static int VK_F9; public final static int VK_F10; public final static int VK_F11; public final static int VK_F12; public final static int VK_FINAL; public final static int VK_G; public final static int VK_H; public final static int VK_HELP; public final static int VK_HOME; public final static int VK_I; public final static int VK_INSERT; public final static int VK_J; public final static int VK_K; public final static int VK_KANA; public final static int VK_KANJI; public final static int VK_L; public final static int VK_LEFT; public final static int VK_M; public final static int VK_META; public final static int VK_MODECHANGE; public final static int VK_MULTIPLY; public final static int VK_N; public final static int VK_NONCONVERT; public final static int VK_NUM_LOCK; public final static int VK_NUMPAD0; public final static int VK_NUMPAD1; public final static int VK_NUMPAD2; public final static int VK_NUMPAD3; public final static int VK_NUMPAD4; public final static int VK_NUMPAD5; public final static int VK_NUMPAD6; public final static int VK_NUMPAD7; public final static int VK_NUMPAD8; public final static int VK_NUMPAD9; public final static int VK_O; public final static int VK_OPEN_BRACKET; public final static int VK_P; public final static int VK_PAGE_DOWN; public final static int VK_PAGE_UP; public final static int VK_PAUSE; public final static int VK_PERIOD; public final static int VK_PRINTSCREEN; public final static int VK_Q; public final static int VK_QUOTE; public final static int VK_R; public final static int VK_RIGHT; public final static int VK_S; public final static int VK_SCROLL_LOCK; public final static int VK_SEMICOLON; public final static int VK_SEPARATER; public final static int VK_SHIFT; public final static int VK_SLASH; public final static int VK_SPACE; public final static int VK_SUBTRACT; public final static int VK_T; public final static int VK_TAB; public final static int VK_U; public final static int VK_UNDEFINED; public final static int VK_UP; public final static int VK_V; public final static int VK_W; public final static int VK_X; public final static int VK_Y; public final static int VK_Z; // Constructors public KeyEvent (Component source, int id, long when, int modifiers, int keyCode, char keyChar); // Class Methods public static String getKeyModifiersText(int modifiers); public static String getKeyText(int keyCode); // Instance Methods public char getKeyChar(); public int getKeyCode(); public boolean isActionKey(); public String paramString(); public void setKeyChar (char keyChar); public void setKeyCode (int keyCode); public void setModifiers (int modifiers); }
This constant is used for key presses have that no associated character.
Specifies the beginning range of key event ID values.
Specifies the ending range of key event ID values.
An event ID type for a key press.
An event ID type for a key release.
An event ID type for a typed key (a press and a release).
The 0 key.
The 1 key.
The 2 key.
The 3 key.
The 4 key.
The 5 key.
The 6 key.
The 7 key.
The 8 key.
The 9 key.
The `a' key.
This constant is used for Asian keyboards.
The plus (+) key on the numeric keypad.
The Alt key.
The `b' key.
The backquote (`) key.
The backslash key.
The Backspace key.
The `c' key.
The Cancel key.
The Caps Lock key.
The Clear key.
The close bracket `]' key.
The comma (,) key.
The Control key.
This constant is used for Asian keyboards.
The `d' key.
The decimal (.) key on the numeric keypad.
The Delete key.
The divide (/) key on the numeric keypad.
The Down arrow key.
The `e' key.
The End key.
The Enter key.
The equals (=) key.
The Escape key.
The `f' key.
The F1 key.
The F2 key.
The F3 key.
The F4 key.
The F5 key.
The F6 key.
The F7 key.
The F8 key.
The F9 key.
The F10 key.
The F11 key.
The F12 key.
This constant is used for Asian keyboards.
The `g' key.
The `h' key.
The Help key.
The Home key.
The `i' key.
The Insert key.
The `j' key.
The `k' key.
This constant is used for Asian keyboards.
This constant is used for Asian keyboards.
The `l' key.
The Left arrow key.
The `m' key.
This constant is used for Asian keyboards.
The Meta key.
The * key on the numeric keypad.
The `n' key.
This constant is used for Asian keyboards.
The Num Lock key.
The 0 key on the numeric keypad.
The 1 key on the numeric keypad.
The 2 key on the numeric keypad.
The 3 key on the numeric keypad.
The 4 key on the numeric keypad.
The 5 key on the numeric keypad.
The 6 key on the numeric keypad.
The 7 key on the numeric keypad.
The 8 key on the numeric keypad.
The 9 key on the numeric keypad.
The `o' key.
The open bracket `[` key.
The `p' key.
The Page Down key.
The Page Up key.
The Pause key.
The period (.) key.
The Print Screen key.
The `q' key.
The quotation mark (") key.
The `r' key.
The Right arrow key.
The `s' key.
The Scroll Lock key.
The semicolon (;) key.
The numeric separator key on the numeric keypad (i.e., the locale-dependent key used to separate groups of digits). A misspelling of VK_SEPARATOR.
The Shift key.
The slash (/) key.
The space key.
The subtract (-) key on the numeric keypad.
The `t' key.
The Tab key.
The `u' key.
An undefined key.
The Up arrow key.
The `v' key.
The `w' key.
The `x' key.
The `y' key.
The `z' key.
The object that generated the event.
The event type ID of the event.
When the event occurred, in milliseconds from the epoch.
What modifier keys were pressed with this key.
The code of the key.
The character for this key.
Constructs a KeyEvent with the given characteristics.
One or more modifier keys.
A string describing the modifiers.
One of the key codes.
A string describing the given key.
The character corresponding to this event. KEY_TYPED events have characters.
The integer key code corresponding to this event. This will be one of the constants defined above. KEY_PRESSED and KEY_RELEASED events have codes. Key codes are virtual keys, not actual. Pressing the `a' key is identical to `A', but has different modifiers. Same for `/' and `?' on a standard keyboard.
true if this event is for one of the action keys; false otherwise.
In general, an action key is a key that causes an action but has no printing equivalent. The action keys are the function keys, the arrow keys, Caps Lock, End, Home, Insert, Num Lock, Pause, Page Down, Page Up, Print Screen, and Scroll Lock. They do not generate a KEY_TYPED event, only KEY_PRESSED and KEY_RELEASED.
A string with current settings of the KeyEvent.
ComponentEvent.paramString()
Helper method for toString() to generate string of current settings.
The new key character.
Sets the character code of this KeyEvent.
The new key code.
Sets the key code of this KeyEvent.
The new modifiers.
This is a combination of the mask constants defined in java.awt.event.InputEvent.
Component, ComponentEvent, InputEvent, KeyAdapter, KeyListener