All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.event.KeyEvent
java.lang.Object
|
+----java.util.EventObject
|
+----java.awt.AWTEvent
|
+----java.awt.event.ComponentEvent
|
+----java.awt.event.InputEvent
|
+----java.awt.event.KeyEvent
- public class KeyEvent
- extends InputEvent
The component-level keyboard event.
-
CHAR_UNDEFINED
- KEY_PRESSED and KEY_RELEASED events which do not map to a
valid Unicode character do not have a defined keyChar.
-
KEY_FIRST
- Marks the first integer id for the range of key event ids.
-
KEY_LAST
- Marks the last integer id for the range of key event ids.
-
KEY_PRESSED
- The key pressed event type.
-
KEY_RELEASED
- The key released event type.
-
KEY_TYPED
- The key typed event type.
-
VK_0
- VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39)
-
VK_1
-
-
VK_2
-
-
VK_3
-
-
VK_4
-
-
VK_5
-
-
VK_6
-
-
VK_7
-
-
VK_8
-
-
VK_9
-
-
VK_A
- VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A)
-
VK_ACCEPT
-
-
VK_ADD
-
-
VK_ALT
-
-
VK_B
-
-
VK_BACK_QUOTE
-
-
VK_BACK_SLASH
-
-
VK_BACK_SPACE
-
-
VK_C
-
-
VK_CANCEL
-
-
VK_CAPS_LOCK
-
-
VK_CLEAR
-
-
VK_CLOSE_BRACKET
-
-
VK_COMMA
-
-
VK_CONTROL
-
-
VK_CONVERT
-
-
VK_D
-
-
VK_DECIMAL
-
-
VK_DELETE
-
-
VK_DIVIDE
-
-
VK_DOWN
-
-
VK_E
-
-
VK_END
-
-
VK_ENTER
- Virtual key codes.
-
VK_EQUALS
-
-
VK_ESCAPE
-
-
VK_F
-
-
VK_F1
-
-
VK_F10
-
-
VK_F11
-
-
VK_F12
-
-
VK_F2
-
-
VK_F3
-
-
VK_F4
-
-
VK_F5
-
-
VK_F6
-
-
VK_F7
-
-
VK_F8
-
-
VK_F9
-
-
VK_FINAL
- for Asian Keyboard
-
VK_G
-
-
VK_H
-
-
VK_HELP
-
-
VK_HOME
-
-
VK_I
-
-
VK_INSERT
-
-
VK_J
-
-
VK_K
-
-
VK_KANA
-
-
VK_KANJI
-
-
VK_L
-
-
VK_LEFT
-
-
VK_M
-
-
VK_META
-
-
VK_MODECHANGE
-
-
VK_MULTIPLY
-
-
VK_N
-
-
VK_NONCONVERT
-
-
VK_NUM_LOCK
-
-
VK_NUMPAD0
-
-
VK_NUMPAD1
-
-
VK_NUMPAD2
-
-
VK_NUMPAD3
-
-
VK_NUMPAD4
-
-
VK_NUMPAD5
-
-
VK_NUMPAD6
-
-
VK_NUMPAD7
-
-
VK_NUMPAD8
-
-
VK_NUMPAD9
-
-
VK_O
-
-
VK_OPEN_BRACKET
-
-
VK_P
-
-
VK_PAGE_DOWN
-
-
VK_PAGE_UP
-
-
VK_PAUSE
-
-
VK_PERIOD
-
-
VK_PRINTSCREEN
-
-
VK_Q
-
-
VK_QUOTE
-
-
VK_R
-
-
VK_RIGHT
-
-
VK_S
-
-
VK_SCROLL_LOCK
-
-
VK_SEMICOLON
-
-
VK_SEPARATER
-
-
VK_SHIFT
-
-
VK_SLASH
-
-
VK_SPACE
-
-
VK_SUBTRACT
-
-
VK_T
-
-
VK_TAB
-
-
VK_U
-
-
VK_UNDEFINED
- KEY_TYPED events do not have a defined keyCode.
-
VK_UP
-
-
VK_V
-
-
VK_W
-
-
VK_X
-
-
VK_Y
-
-
VK_Z
-
-
KeyEvent(Component, int, long, int, int)
-
-
KeyEvent(Component, int, long, int, int, char)
- Constructs a KeyEvent object with the specified source component,
type, modifiers, and key.
-
getKeyChar()
- Returns the character associated with the key in this event.
-
getKeyCode()
- Returns the integer key-code associated with the key in this event.
-
getKeyModifiersText(int)
- Returns a String describing the modifier key(s), such as "Shift",
or "Ctrl+Shift".
-
getKeyText(int)
- Returns a String describing the keyCode, such as "HOME", "F1" or "A".
-
isActionKey()
- Returns whether or not the key in this event is an "action" key.
-
paramString()
-
-
setKeyChar(char)
-
-
setKeyCode(int)
-
-
setModifiers(int)
-
KEY_FIRST
Properties Public Constant
KEY_FIRST=int
- Marks the first integer id for the range of key event ids.
KEY_LAST
Properties Public Constant
KEY_LAST=int
- Marks the last integer id for the range of key event ids.
KEY_TYPED
Properties Public Constant
KEY_TYPED=int
- The key typed event type. This type is generated by a combination
of a key press followed by a key release.
KEY_PRESSED
Properties Public Constant
KEY_PRESSED=int
- The key pressed event type.
KEY_RELEASED
Properties Public Constant
KEY_RELEASED=int
- The key released event type.
VK_ENTER
Properties Public Constant
VK_ENTER=int
- Virtual key codes. These codes report which keyboard key has
been pressed, rather than any character generated by one or more
keys being pressed.
For example, pressing the Shift key will cause a KEY_PRESSED event
with a VK_SHIFT keyCode, while pressing the 'a' key will result in
a VK_A keyCode. After the 'a' key is released, a KEY_RELEASED event
will be fired with VK_A, followed by a KEY_TYPED event with a keyChar
value of 'A'. Key combinations which do not result in characters,
such as action keys like F1, will not generate KEY_TYPED events.
Note: not all keyboards or systems are capable of generating all
virtual key codes. No attempt is made in Java to artificially
generate these keys.
WARNING: aside from those keys where are defined by the Java language
(VK_ENTER, VK_BACK_SPACE, and VK_TAB), do not rely on the values of these
constants. Sun reserves the right to change these values as needed
to accomodate a wider range of keyboards in the future.
VK_BACK_SPACE
Properties Public Constant
VK_BACK_SPACE=int
VK_TAB
Properties Public Constant
VK_TAB=int
VK_CANCEL
Properties Public Constant
VK_CANCEL=int
VK_CLEAR
Properties Public Constant
VK_CLEAR=int
VK_SHIFT
Properties Public Constant
VK_SHIFT=int
VK_CONTROL
Properties Public Constant
VK_CONTROL=int
VK_ALT
Properties Public Constant
VK_ALT=int
VK_PAUSE
Properties Public Constant
VK_PAUSE=int
VK_CAPS_LOCK
Properties Public Constant
VK_CAPS_LOCK=int
VK_ESCAPE
Properties Public Constant
VK_ESCAPE=int
VK_SPACE
Properties Public Constant
VK_SPACE=int
VK_PAGE_UP
Properties Public Constant
VK_PAGE_UP=int
VK_PAGE_DOWN
Properties Public Constant
VK_PAGE_DOWN=int
VK_END
Properties Public Constant
VK_END=int
VK_HOME
Properties Public Constant
VK_HOME=int
VK_LEFT
Properties Public Constant
VK_LEFT=int
VK_UP
Properties Public Constant
VK_UP=int
VK_RIGHT
Properties Public Constant
VK_RIGHT=int
VK_DOWN
Properties Public Constant
VK_DOWN=int
VK_COMMA
Properties Public Constant
VK_COMMA=int
VK_PERIOD
Properties Public Constant
VK_PERIOD=int
VK_SLASH
Properties Public Constant
VK_SLASH=int
VK_0
Properties Public Constant
VK_0=int
- VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39)
VK_1
Properties Public Constant
VK_1=int
VK_2
Properties Public Constant
VK_2=int
VK_3
Properties Public Constant
VK_3=int
VK_4
Properties Public Constant
VK_4=int
VK_5
Properties Public Constant
VK_5=int
VK_6
Properties Public Constant
VK_6=int
VK_7
Properties Public Constant
VK_7=int
VK_8
Properties Public Constant
VK_8=int
VK_9
Properties Public Constant
VK_9=int
VK_SEMICOLON
Properties Public Constant
VK_SEMICOLON=int
VK_EQUALS
Properties Public Constant
VK_EQUALS=int
VK_A
Properties Public Constant
VK_A=int
- VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A)
VK_B
Properties Public Constant
VK_B=int
VK_C
Properties Public Constant
VK_C=int
VK_D
Properties Public Constant
VK_D=int
VK_E
Properties Public Constant
VK_E=int
VK_F
Properties Public Constant
VK_F=int
VK_G
Properties Public Constant
VK_G=int
VK_H
Properties Public Constant
VK_H=int
VK_I
Properties Public Constant
VK_I=int
VK_J
Properties Public Constant
VK_J=int
VK_K
Properties Public Constant
VK_K=int
VK_L
Properties Public Constant
VK_L=int
VK_M
Properties Public Constant
VK_M=int
VK_N
Properties Public Constant
VK_N=int
VK_O
Properties Public Constant
VK_O=int
VK_P
Properties Public Constant
VK_P=int
VK_Q
Properties Public Constant
VK_Q=int
VK_R
Properties Public Constant
VK_R=int
VK_S
Properties Public Constant
VK_S=int
VK_T
Properties Public Constant
VK_T=int
VK_U
Properties Public Constant
VK_U=int
VK_V
Properties Public Constant
VK_V=int
VK_W
Properties Public Constant
VK_W=int
VK_X
Properties Public Constant
VK_X=int
VK_Y
Properties Public Constant
VK_Y=int
VK_Z
Properties Public Constant
VK_Z=int
VK_OPEN_BRACKET
Properties Public Constant
VK_OPEN_BRACKET=int
VK_BACK_SLASH
Properties Public Constant
VK_BACK_SLASH=int
VK_CLOSE_BRACKET
Properties Public Constant
VK_CLOSE_BRACKET=int
VK_NUMPAD0
Properties Public Constant
VK_NUMPAD0=int
VK_NUMPAD1
Properties Public Constant
VK_NUMPAD1=int
VK_NUMPAD2
Properties Public Constant
VK_NUMPAD2=int
VK_NUMPAD3
Properties Public Constant
VK_NUMPAD3=int
VK_NUMPAD4
Properties Public Constant
VK_NUMPAD4=int
VK_NUMPAD5
Properties Public Constant
VK_NUMPAD5=int
VK_NUMPAD6
Properties Public Constant
VK_NUMPAD6=int
VK_NUMPAD7
Properties Public Constant
VK_NUMPAD7=int
VK_NUMPAD8
Properties Public Constant
VK_NUMPAD8=int
VK_NUMPAD9
Properties Public Constant
VK_NUMPAD9=int
VK_MULTIPLY
Properties Public Constant
VK_MULTIPLY=int
VK_ADD
Properties Public Constant
VK_ADD=int
VK_SEPARATER
Properties Public Constant
VK_SEPARATER=int
VK_SUBTRACT
Properties Public Constant
VK_SUBTRACT=int
VK_DECIMAL
Properties Public Constant
VK_DECIMAL=int
VK_DIVIDE
Properties Public Constant
VK_DIVIDE=int
VK_F1
Properties Public Constant
VK_F1=int
VK_F2
Properties Public Constant
VK_F2=int
VK_F3
Properties Public Constant
VK_F3=int
VK_F4
Properties Public Constant
VK_F4=int
VK_F5
Properties Public Constant
VK_F5=int
VK_F6
Properties Public Constant
VK_F6=int
VK_F7
Properties Public Constant
VK_F7=int
VK_F8
Properties Public Constant
VK_F8=int
VK_F9
Properties Public Constant
VK_F9=int
VK_F10
Properties Public Constant
VK_F10=int
VK_F11
Properties Public Constant
VK_F11=int
VK_F12
Properties Public Constant
VK_F12=int
VK_DELETE
Properties Public Constant
VK_DELETE=int
VK_NUM_LOCK
Properties Public Constant
VK_NUM_LOCK=int
VK_SCROLL_LOCK
Properties Public Constant
VK_SCROLL_LOCK=int
VK_PRINTSCREEN
Properties Public Constant
VK_PRINTSCREEN=int
VK_INSERT
Properties Public Constant
VK_INSERT=int
VK_HELP
Properties Public Constant
VK_HELP=int
VK_META
Properties Public Constant
VK_META=int
VK_BACK_QUOTE
Properties Public Constant
VK_BACK_QUOTE=int
VK_QUOTE
Properties Public Constant
VK_QUOTE=int
VK_FINAL
Properties Public Constant
VK_FINAL=int
- for Asian Keyboard
VK_CONVERT
Properties Public Constant
VK_CONVERT=int
VK_NONCONVERT
Properties Public Constant
VK_NONCONVERT=int
VK_ACCEPT
Properties Public Constant
VK_ACCEPT=int
VK_MODECHANGE
Properties Public Constant
VK_MODECHANGE=int
VK_KANA
Properties Public Constant
VK_KANA=int
VK_KANJI
Properties Public Constant
VK_KANJI=int
VK_UNDEFINED
Properties Public Constant
VK_UNDEFINED=int
- KEY_TYPED events do not have a defined keyCode.
CHAR_UNDEFINED
Properties Public Constant
CHAR_UNDEFINED=char
- KEY_PRESSED and KEY_RELEASED events which do not map to a
valid Unicode character do not have a defined keyChar.
KeyEvent
method KeyEvent(source=Component, -
id=int, -
when=long, -
modifiers=int, -
keyCode=int, -
keyChar=char) public
- Constructs a KeyEvent object with the specified source component,
type, modifiers, and key.
- Parameters:
- source - the object where the event originated
KeyEvent
method KeyEvent(source=Component, -
id=int, -
when=long, -
modifiers=int, -
keyCode=int) public
getKeyCode
method getKeyCode() returns int public
- Returns the integer key-code associated with the key in this event.
For KEY_TYPED events, keyCode is VK_UNDEFINED.
setKeyCode
method setKeyCode(keyCode=int) public
setKeyChar
method setKeyChar(keyChar=char) public
setModifiers
method setModifiers(modifiers=int) public
getKeyChar
method getKeyChar() returns char public
- Returns the character associated with the key in this event.
If no valid Unicode character exists for this key event, keyChar
is CHAR_UNDEFINED.
getKeyText
method getKeyText(keyCode=int) returns String public static
- Returns a String describing the keyCode, such as "HOME", "F1" or "A".
These strings can be localized by changing the awt.properties file.
getKeyModifiersText
method getKeyModifiersText(modifiers=int) returns String public static
- Returns a String describing the modifier key(s), such as "Shift",
or "Ctrl+Shift". These strings can be localized by changing the
awt.properties file.
isActionKey
method isActionKey() returns boolean public
- Returns whether or not the key in this event is an "action" key.
paramString
method paramString() returns String public
- Overrides:
- paramString in class ComponentEvent
All Packages Class Hierarchy This Package Previous Next Index