java.awt.event
Class KeyEvent
java.lang.Object
|
+--java.util.EventObject
|
+--java.awt.AWTEvent
|
+--java.awt.event.ComponentEvent
|
+--java.awt.event.InputEvent
|
+--java.awt.event.KeyEvent
This event is generated when a key is pressed or released. There are two
categories of key events:
"Key typed" events are higher-level, and have already
compensated for modifiers and keyboard layout to generate a single Unicode
character. It may take several key press events to generate one key typed.
The getKeyCode method will return VK_UNDEFINED,
and getKeyChar will return a valid Unicode character or
CHAR_UNDEFINED.
"Key pressed" and "key released" events are lower-level, and
are platform and keyboard dependent. They correspond to the actaul motion
on a keyboard, and return a virtual key code which labels the key that was
pressed. The getKeyCode method will return one of the
VK_* constants (except VK_UNDEFINED), and the
getKeyChar method is undefined.
Some keys do not generate key typed events, such as the F1 or HELP keys.
Not all keyboards can generate all virtual keys, and no attempt is made to
simulate the ones that can't be typed. Virtual keys correspond to the
keyboard layout, so for example, VK_Q in English is VK_A in French. Also,
there are some additional virtual keys to ease handling of actions, such
as VK_ALL_CANDIDATES in place of ALT+VK_CONVERT. Do not rely on the value
of the VK_* constants, except for VK_ENTER, VK_BACK_SPACE, and VK_TAB.
Since:Authors:- Aaron M. Renn <arenn@urbanophile.com>
- Eric Blake <ebb9@email.byu.edu>
See Also:
KeyEvent(java.awt.Component source, int id, long when, int modifiers, int keyCode, char keyChar, int keyLocation)
|
KeyEvent(java.awt.Component source, int id, long when, int modifiers, int keyCode, char keyChar)
|
KeyEvent(java.awt.Component source, int id, long when, int modifiers, int keyCode)
|
CHAR_UNDEFINED
public static final char CHAR_UNDEFINED The only char with no valid Unicode interpretation. This is used for
key pressed and key released events which do not have a valid keyChar.
KEY_FIRST
public static final int KEY_FIRSTThis is the first id in the range of event ids used by this class.
KEY_LAST
public static final int KEY_LASTThis is the last id in the range of event ids used by this class.
KEY_LOCATION_LEFT
public static final int KEY_LOCATION_LEFT Indicates the key is on the left side of the keyboard, such as the left
shift.
Since:
KEY_LOCATION_NUMPAD
public static final int KEY_LOCATION_NUMPAD Indicates the key is on the numeric pad, such as the numpad 0.
Since:
KEY_LOCATION_RIGHT
public static final int KEY_LOCATION_RIGHT Indicates the key is on the right side of the keyboard, such as the right
shift.
Since:
KEY_LOCATION_STANDARD
public static final int KEY_LOCATION_STANDARD Indicates a standard key location, with no left/right variants and not
on the numeric pad.
Since:
KEY_LOCATION_UNKNOWN
public static final int KEY_LOCATION_UNKNOWN Indicates unknown or irrelavent key location. This is also used for
key typed events, which do not need a location.
Since:
KEY_PRESSED
public static final int KEY_PRESSEDThis event id indicates a key was pressed.
KEY_RELEASED
public static final int KEY_RELEASEDThis event it indicates a key was released.
KEY_TYPED
public static final int KEY_TYPED This event id indicates a key was typed, which is a key press followed
by a key release to generate an actual Unicode character. It may take
several key presses to generate one key typed event, and some action
keys have no corresponding key typed.
VK_0
public static final int VK_0The virtual key VK_0.
VK_1
public static final int VK_1The virtual key VK_1.
VK_2
public static final int VK_2The virtual key VK_2.
VK_3
public static final int VK_3The virtual key VK_3.
VK_4
public static final int VK_4The virtual key VK_4.
VK_5
public static final int VK_5The virtual key VK_5.
VK_6
public static final int VK_6The virtual key VK_6.
VK_7
public static final int VK_7The virtual key VK_7.
VK_8
public static final int VK_8The virtual key VK_8.
VK_9
public static final int VK_9The virtual key VK_9.
VK_A
public static final int VK_AThe virtual key VK_A.
VK_ACCEPT
public static final int VK_ACCEPTThe virtual key VK_ACCEPT.
VK_ADD
public static final int VK_ADDThe virtual key VK_ADD.
VK_AGAIN
public static final int VK_AGAIN The virtual key VK_AGAIN.
Since:
VK_ALL_CANDIDATES
public static final int VK_ALL_CANDIDATES The virtual key VK_ALL_CANDIDATES.
Since:
VK_ALPHANUMERIC
public static final int VK_ALPHANUMERIC The virtual key VK_ALPHANUMERIC.
Since:
VK_ALT
public static final int VK_ALTThe virtual key VK_ALT.
VK_ALT_GRAPH
public static final int VK_ALT_GRAPH The virtual key VK_ALT_GRAPH.
Since:
VK_AMPERSAND
public static final int VK_AMPERSAND The virtual key VK_AMPERSAND.
Since:
VK_ASTERISK
public static final int VK_ASTERISK The virtual key VK_ASTERISK.
Since:
VK_AT
public static final int VK_AT The virtual key VK_AT.
Since:
VK_B
public static final int VK_BThe virtual key VK_B.
VK_BACK_QUOTE
public static final int VK_BACK_QUOTEThe virtual key VK_BACK_QUOTE.
VK_BACK_SLASH
public static final int VK_BACK_SLASHThe virtual key VK_BACK_SLASH.
VK_BACK_SPACE
public static final int VK_BACK_SPACEThe virtual key Backspace, which will always map to '\b'.
VK_BRACELEFT
public static final int VK_BRACELEFT The virtual key VK_BRACELEFT.
Since:
VK_BRACERIGHT
public static final int VK_BRACERIGHT The virtual key VK_BRACERIGHT.
Since:
VK_C
public static final int VK_CThe virtual key VK_C.
VK_CANCEL
public static final int VK_CANCELThe virtual key Cancel.
VK_CAPS_LOCK
public static final int VK_CAPS_LOCKThe virtual key VK_CAPS_LOCK.
VK_CIRCUMFLEX
public static final int VK_CIRCUMFLEX The virtual key VK_CIRCUMFLEX.
Since:
VK_CLEAR
public static final int VK_CLEARThe virtual key VK_CLEAR.
VK_CLOSE_BRACKET
public static final int VK_CLOSE_BRACKETThe virtual key VK_CLOSE_BRACKET.
VK_CODE_INPUT
public static final int VK_CODE_INPUT The virtual key VK_CODE_INPUT.
Since:
VK_COLON
public static final int VK_COLON The virtual key VK_COLON.
Since:
VK_COMMA
public static final int VK_COMMAThe virtual key VK_COMMA.
VK_COMPOSE
public static final int VK_COMPOSE The virtual key VK_COMPOSE.
Since:
VK_CONTROL
public static final int VK_CONTROLThe virtual key VK_CONTROL.
VK_CONVERT
public static final int VK_CONVERTThe virtual key VK_CONVERT.
VK_COPY
public static final int VK_COPY The virtual key VK_COPY.
Since:
VK_CUT
public static final int VK_CUT The virtual key VK_CUT.
Since:
VK_D
public static final int VK_DThe virtual key VK_D.
VK_DEAD_ABOVEDOT
public static final int VK_DEAD_ABOVEDOT The virtual key VK_DEAD_ABOVEDOT.
Since:
VK_DEAD_ABOVERING
public static final int VK_DEAD_ABOVERING The virtual key VK_DEAD_ABOVERING.
Since:
VK_DEAD_ACUTE
public static final int VK_DEAD_ACUTE The virtual key VK_DEAD_ACUTE.
Since:
VK_DEAD_BREVE
public static final int VK_DEAD_BREVE The virtual key VK_DEAD_BREVE.
Since:
VK_DEAD_CARON
public static final int VK_DEAD_CARON The virtual key VK_DEAD_CARON.
Since:
VK_DEAD_CEDILLA
public static final int VK_DEAD_CEDILLA The virtual key VK_DEAD_CEDILLA.
Since:
VK_DEAD_CIRCUMFLEX
public static final int VK_DEAD_CIRCUMFLEX The virtual key VK_DEAD_CIRCUMFLEX.
Since:
VK_DEAD_DIAERESIS
public static final int VK_DEAD_DIAERESIS The virtual key VK_DEAD_DIAERESIS.
Since:
VK_DEAD_DOUBLEACUTE
public static final int VK_DEAD_DOUBLEACUTE The virtual key VK_DEAD_DOUBLEACUTE.
Since:
VK_DEAD_GRAVE
public static final int VK_DEAD_GRAVE The virtual key VK_DEAD_GRAVE.
Since:
VK_DEAD_IOTA
public static final int VK_DEAD_IOTA The virtual key VK_DEAD_IOTA.
Since:
VK_DEAD_MACRON
public static final int VK_DEAD_MACRON The virtual key VK_DEAD_MACRON.
Since:
VK_DEAD_OGONEK
public static final int VK_DEAD_OGONEK The virtual key VK_DEAD_OGONEK.
Since:
VK_DEAD_SEMIVOICED_SOUND
public static final int VK_DEAD_SEMIVOICED_SOUND The virtual key VK_DEAD_SEMIVOICED_SOUND.
Since:
VK_DEAD_TILDE
public static final int VK_DEAD_TILDE The virtual key VK_DEAD_TILDE.
Since:
VK_DEAD_VOICED_SOUND
public static final int VK_DEAD_VOICED_SOUND The virtual key VK_DEAD_VOICED_SOUND.
Since:
VK_DECIMAL
public static final int VK_DECIMALThe virtual key VK_DECIMAL.
VK_DELETE
public static final int VK_DELETEThe virtual key VK_DELETE.
VK_DIVIDE
public static final int VK_DIVIDEThe virtual key VK_DIVIDE.
VK_DOLLAR
public static final int VK_DOLLAR The virtual key VK_DOLLAR.
Since:
VK_DOWN
public static final int VK_DOWN The virtual key for the non-numpad VK_DOWN.
See Also:
VK_E
public static final int VK_EThe virtual key VK_E.
VK_END
public static final int VK_ENDThe virtual key VK_END.
VK_ENTER
public static final int VK_ENTERThe virtual key Enter, which will always map to '\n'.
VK_EQUALS
public static final int VK_EQUALSThe virtual key VK_EQUALS.
VK_ESCAPE
public static final int VK_ESCAPEThe virtual key VK_ESCAPE.
VK_EURO_SIGN
public static final int VK_EURO_SIGN The virtual key VK_EURO_SIGN.
Since:
VK_EXCLAMATION_MARK
public static final int VK_EXCLAMATION_MARK The virtual key VK_EXCLAMATION_MARK.
Since:
VK_F
public static final int VK_FThe virtual key VK_F.
VK_F1
public static final int VK_F1The virtual key VK_F1.
VK_F10
public static final int VK_F10The virtual key VK_F10.
VK_F11
public static final int VK_F11The virtual key VK_F11.
VK_F12
public static final int VK_F12The virtual key VK_F12.
VK_F13
public static final int VK_F13 The virtual key VK_F13.
Since:
VK_F14
public static final int VK_F14 The virtual key VK_F14.
Since:
VK_F15
public static final int VK_F15 The virtual key VK_F15.
Since:
VK_F16
public static final int VK_F16 The virtual key VK_F16.
Since:
VK_F17
public static final int VK_F17 The virtual key VK_F17.
Since:
VK_F18
public static final int VK_F18 The virtual key VK_F18.
Since:
VK_F19
public static final int VK_F19 The virtual key VK_F19.
Since:
VK_F2
public static final int VK_F2The virtual key VK_F2.
VK_F20
public static final int VK_F20 The virtual key VK_F20.
Since:
VK_F21
public static final int VK_F21 The virtual key VK_F21.
Since:
VK_F22
public static final int VK_F22 The virtual key VK_F22.
Since:
VK_F23
public static final int VK_F23 The virtual key VK_F23.
Since:
VK_F24
public static final int VK_F24 The virtual key VK_F24.
Since:
VK_F3
public static final int VK_F3The virtual key VK_F3.
VK_F4
public static final int VK_F4The virtual key VK_F4.
VK_F5
public static final int VK_F5The virtual key VK_F5.
VK_F6
public static final int VK_F6The virtual key VK_F6.
VK_F7
public static final int VK_F7The virtual key VK_F7.
VK_F8
public static final int VK_F8The virtual key VK_F8.
VK_F9
public static final int VK_F9The virtual key VK_F9.
VK_FINAL
public static final int VK_FINALThe virtual key VK_FINAL.
VK_FIND
public static final int VK_FIND The virtual key VK_FIND.
Since:
VK_FULL_WIDTH
public static final int VK_FULL_WIDTH The virtual key VK_FULL_WIDTH.
Since:
VK_G
public static final int VK_GThe virtual key VK_G.
VK_GREATER
public static final int VK_GREATER The virtual key VK_GREATER.
Since:
VK_H
public static final int VK_HThe virtual key VK_H.
VK_HALF_WIDTH
public static final int VK_HALF_WIDTH The virtual key VK_HALF_WIDTH.
Since:
VK_HELP
public static final int VK_HELPThe virtual key VK_HELP.
VK_HIRAGANA
public static final int VK_HIRAGANA The virtual key VK_HIRAGANA.
Since:
VK_HOME
public static final int VK_HOMEThe virtual key VK_HOME.
VK_I
public static final int VK_IThe virtual key VK_I.
VK_INPUT_METHOD_ON_OFF
public static final int VK_INPUT_METHOD_ON_OFF The virtual key VK_INPUT_METHOD_ON_OFF.
Since:
VK_INSERT
public static final int VK_INSERTThe virtual key VK_INSERT.
VK_INVERTED_EXCLAMATION_MARK
public static final int VK_INVERTED_EXCLAMATION_MARK The virtual key VK_INVERTED_EXCLAMATION_MARK.
Since:
VK_J
public static final int VK_JThe virtual key VK_J.
VK_JAPANESE_HIRAGANA
public static final int VK_JAPANESE_HIRAGANA The virtual key VK_JAPANESE_HIRAGANA.
Since:
VK_JAPANESE_KATAKANA
public static final int VK_JAPANESE_KATAKANA The virtual key VK_JAPANESE_KATAKANA.
Since:
VK_JAPANESE_ROMAN
public static final int VK_JAPANESE_ROMAN The virtual key VK_JAPANESE_ROMAN.
Since:
VK_K
public static final int VK_KThe virtual key VK_K.
VK_KANA
public static final int VK_KANAThe virtual key VK_KANA.
VK_KANA_LOCK
public static final int VK_KANA_LOCK The virtual key VK_KANA_LOCK.
Since:
VK_KANJI
public static final int VK_KANJIThe virtual key VK_KANJI.
VK_KATAKANA
public static final int VK_KATAKANA The virtual key VK_KATAKANA.
Since:
VK_KP_DOWN
public static final int VK_KP_DOWN The virtual key for the numpad VK_KP_DOWN.
Since:See Also:
VK_KP_LEFT
public static final int VK_KP_LEFT The virtual key for the numpad VK_KP_LEFT.
Since:See Also:
VK_KP_RIGHT
public static final int VK_KP_RIGHT The virtual key for the numpad VK_KP_RIGHT.
Since:See Also:
VK_KP_UP
public static final int VK_KP_UP The virtual key for the numpad VK_KP_UP.
Since:See Also:
VK_L
public static final int VK_LThe virtual key VK_L.
VK_LEFT
public static final int VK_LEFT The virtual key for the non-numpad VK_LEFT.
See Also:
VK_LEFT_PARENTHESIS
public static final int VK_LEFT_PARENTHESIS The virtual key VK_LEFT_PARENTHESIS.
Since:
VK_LESS
public static final int VK_LESS The virtual key VK_LESS.
Since:
VK_M
public static final int VK_MThe virtual key VK_M.
VK_META
public static final int VK_METAThe virtual key VK_META.
VK_MINUS
public static final int VK_MINUS The virtual key VK_MINUS.
Since:
VK_MODECHANGE
public static final int VK_MODECHANGEThe virtual key VK_MODECHANGE.
VK_MULTIPLY
public static final int VK_MULTIPLYThe virtual key VK_MULTIPLY.
VK_N
public static final int VK_NThe virtual key VK_N.
VK_NONCONVERT
public static final int VK_NONCONVERTThe virtual key VK_NONCONVERT.
VK_NUMBER_SIGN
public static final int VK_NUMBER_SIGN The virtual key VK_NUMBER_SIGN.
Since:
VK_NUMPAD0
public static final int VK_NUMPAD0The virtual key VK_NUMPAD0.
VK_NUMPAD1
public static final int VK_NUMPAD1The virtual key VK_NUMPAD1.
VK_NUMPAD2
public static final int VK_NUMPAD2The virtual key VK_NUMPAD2.
VK_NUMPAD3
public static final int VK_NUMPAD3The virtual key VK_NUMPAD3.
VK_NUMPAD4
public static final int VK_NUMPAD4The virtual key VK_NUMPAD4.
VK_NUMPAD5
public static final int VK_NUMPAD5The virtual key VK_NUMPAD5.
VK_NUMPAD6
public static final int VK_NUMPAD6The virtual key VK_NUMPAD6.
VK_NUMPAD7
public static final int VK_NUMPAD7The virtual key VK_NUMPAD7.
VK_NUMPAD8
public static final int VK_NUMPAD8The virtual key VK_NUMPAD8.
VK_NUMPAD9
public static final int VK_NUMPAD9The virtual key VK_NUMPAD9.
VK_NUM_LOCK
public static final int VK_NUM_LOCKThe virtual key VK_NUM_LOCK.
VK_O
public static final int VK_OThe virtual key VK_O.
VK_OPEN_BRACKET
public static final int VK_OPEN_BRACKETThe virtual key VK_OPEN_BRACKET.
VK_P
public static final int VK_PThe virtual key VK_P.
VK_PAGE_DOWN
public static final int VK_PAGE_DOWNThe virtual key VK_PAGE_DOWN.
VK_PAGE_UP
public static final int VK_PAGE_UPThe virtual key VK_PAGE_UP.
VK_PASTE
public static final int VK_PASTE The virtual key VK_PASTE.
Since:
VK_PAUSE
public static final int VK_PAUSEThe virtual key VK_PAUSE.
VK_PERIOD
public static final int VK_PERIODThe virtual key VK_PERIOD.
VK_PLUS
public static final int VK_PLUS The virtual key VK_PLUS.
Since:
VK_PREVIOUS_CANDIDATE
public static final int VK_PREVIOUS_CANDIDATE The virtual key VK_PREVIOUS_CANDIDATE.
Since:
VK_PRINTSCREEN
public static final int VK_PRINTSCREENThe virtual key VK_PRINTSCREEN.
VK_PROPS
public static final int VK_PROPS The virtual key VK_PROPS.
Since:
VK_Q
public static final int VK_QThe virtual key VK_Q.
VK_QUOTE
public static final int VK_QUOTEThe virtual key VK_QUOTE.
VK_QUOTEDBL
public static final int VK_QUOTEDBL The virtual key VK_QUOTEDBL.
Since:
VK_R
public static final int VK_RThe virtual key VK_R.
VK_RIGHT
public static final int VK_RIGHT The virtual key for the non-numpad VK_RIGHT.
See Also:
VK_RIGHT_PARENTHESIS
public static final int VK_RIGHT_PARENTHESIS The virtual key VK_RIGHT_PARENTHESIS.
Since:
VK_ROMAN_CHARACTERS
public static final int VK_ROMAN_CHARACTERS The virtual key VK_ROMAN_CHARACTERS.
Since:
VK_S
public static final int VK_SThe virtual key VK_S.
VK_SCROLL_LOCK
public static final int VK_SCROLL_LOCKThe virtual key VK_SCROLL_LOCK.
VK_SEMICOLON
public static final int VK_SEMICOLONThe virtual key VK_SEMICOLON.
VK_SEPARATER
public static final int VK_SEPARATER The virtual key VK_SEPARATOR, handily mispelled for those who can't
figure it out.
VK_SEPARATOR
public static final int VK_SEPARATOR The virtual key VK_SEPARATOR.
Since:
VK_SHIFT
public static final int VK_SHIFTThe virtual key VK_SHIFT.
VK_SLASH
public static final int VK_SLASHThe virtual key VK_SLASH.
VK_SPACE
public static final int VK_SPACEThe virtual key VK_SPACE.
VK_STOP
public static final int VK_STOP The virtual key VK_STOP.
Since:
VK_SUBTRACT
public static final int VK_SUBTRACTThe virtual key VK_SUBTRACT.
VK_T
public static final int VK_TThe virtual key VK_T.
VK_TAB
public static final int VK_TABThe virtual key Tab, which will always map to '\t'.
VK_U
public static final int VK_UThe virtual key VK_U.
VK_UNDEFINED
public static final int VK_UNDEFINED The virtual key VK_UNDEFINED. This is used for key typed events, which
do not have a virtual key.
VK_UNDERSCORE
public static final int VK_UNDERSCORE The virtual key VK_UNDERSCORE.
Since:
VK_UNDO
public static final int VK_UNDO The virtual key VK_UNDO.
Since:
VK_UP
public static final int VK_UP The virtual key for the non-numpad VK_UP.
See Also:
VK_V
public static final int VK_VThe virtual key VK_V.
VK_W
public static final int VK_WThe virtual key VK_W.
VK_X
public static final int VK_XThe virtual key VK_X.
VK_Y
public static final int VK_YThe virtual key VK_Y.
VK_Z
public static final int VK_ZThe virtual key VK_Z.
KeyEvent
public KeyEvent(java.awt.Component source, int id, long when, int modifiers, int keyCode) Initializes a new instance of KeyEvent with the specified
information. Note that an invalid id leads to unspecified results.
Parameters:
Throws:
KeyEvent
public KeyEvent(java.awt.Component source, int id, long when, int modifiers, int keyCode, char keyChar) Initializes a new instance of KeyEvent with the specified
information. Note that an invalid id leads to unspecified results.
Parameters:
Throws:
IllegalArgumentException - if source is null, or if
(id == KEY_TYPED && (keyCode != VK_UNDEFINED
|| keyChar == CHAR_UNDEFINED))
KeyEvent
public KeyEvent(java.awt.Component source, int id, long when, int modifiers, int keyCode, char keyChar, int keyLocation) Initializes a new instance of KeyEvent with the specified
information. Note that an invalid id leads to unspecified results.
Parameters:
Throws:
IllegalArgumentException - if source is null, if keyLocation is
invalid, or if (id == KEY_TYPED && (keyCode != VK_UNDEFINED
|| keyChar == CHAR_UNDEFINED))
getKeyChar
public char getKeyChar() Returns the Unicode value for the event key. This will be
CHAR_UNDEFINED if there is no Unicode equivalent for
this key, usually when this is a KEY_PRESSED or KEY_RELEASED event.
Returns:
- the Unicode character for this event
getKeyCode
public int getKeyCode() Returns the key code for the event key. This will be one of the
VK_* constants defined in this class. If the event type is
KEY_TYPED, the result will be VK_UNDEFINED.
Returns:
- the key code for this event
getKeyLocation
public int getKeyLocation() Returns the keyboard location of the key that generated this event. This
provides a way to distinguish between keys like left and right shift
which share a common key code. The result will be one of
#KEY_LOCATION_UNKNOWN, #KEY_LOCATION_STANDARD,
#KEY_LOCATION_LEFT, #KEY_LOCATION_RIGHT, or
#KEY_LOCATION_NUMPAD.
Since:Returns:
getKeyModifiersText
public static String getKeyModifiersText(int modifiers) Returns a string describing the modifiers, such as "Shift" or
"Ctrl+Button1".
XXX Sun claims this can be localized via the awt.properties file - how
do we implement that?
Parameters:
Returns:
- a string representation of the modifiers in this bitmask
getKeyText
public static String getKeyText(int keyCode) Returns the text name of key code, such as "HOME", "F1", or "A".
XXX Sun claims this can be localized via the awt.properties file - how
do we implement that?
Parameters:
Returns:
- the text name of the key code
isActionKey
public boolean isActionKey() Tests whether or not this key is an action key. An action key typically
does not fire a KEY_TYPED event, and is not a modifier.
Returns:
- true if this is an action key
paramString
public String paramString() Returns a string identifying the event. This is formatted as the field
name of the id type, followed by the keyCode, then the keyChar (if
available), modifiers (if any), extModifiers (if any), and keyLocation.
The keyChar is available unless the keyCode is Backspace, Tab, Enter,
Escape, Numpad-[0-9], Delete, or a keyCode which is an action.
Returns:
- a string identifying the event
setKeyChar
public void setKeyChar(char keyChar) Sets the Unicode character for this event to the specified value.
Parameters:
setKeyCode
public void setKeyCode(int keyCode) Sets the key code for this event. This must be one of the
VK_* constants defined in this class.
Parameters:
setModifiers
public void setModifiers(int modifiers) Sets the modifier keys to the specified value. This should be a union
of the bit mask constants from InputEvent. The use of this
method is not recommended, particularly for KEY_TYPED events, which do
not check if the modifiers were changed.
Parameters:
See Also:
"Key typed" events are higher-level, and have already compensated for modifiers and keyboard layout to generate a single Unicode character. It may take several key press events to generate one key typed. The
getKeyCodemethod will returnVK_UNDEFINED, andgetKeyCharwill return a valid Unicode character orCHAR_UNDEFINED."Key pressed" and "key released" events are lower-level, and are platform and keyboard dependent. They correspond to the actaul motion on a keyboard, and return a virtual key code which labels the key that was pressed. The
getKeyCodemethod will return one of theVK_*constants (except VK_UNDEFINED), and thegetKeyCharmethod is undefined.Some keys do not generate key typed events, such as the F1 or HELP keys. Not all keyboards can generate all virtual keys, and no attempt is made to simulate the ones that can't be typed. Virtual keys correspond to the keyboard layout, so for example, VK_Q in English is VK_A in French. Also, there are some additional virtual keys to ease handling of actions, such as VK_ALL_CANDIDATES in place of ALT+VK_CONVERT. Do not rely on the value of the VK_* constants, except for VK_ENTER, VK_BACK_SPACE, and VK_TAB.