java::awt::event::KeyEvent Class Reference

Inheritance diagram for java::awt::event::KeyEvent:

Inheritance graph
java::awt::event::InputEventjava::awt::event::ComponentEventjava::awt::AWTEventjava::util::EventObjectjava::lang::Object
[legend]
Collaboration diagram for java::awt::event::KeyEvent:

Collaboration graph
java::awt::event::InputEventjava::awt::event::ComponentEventjava::awt::AWTEventjava::util::EventObjectjava::lang::Objectjava::lang::ObjectRefjava::lang::Interfacejava::lang::Comparable
[legend]

List of all members.


Detailed Description

An event which indicates that a keystroke occurred in a component.

This low-level event is generated by a component object (such as a text field) when a key is pressed, released, or typed. The event is passed to every KeyListener or KeyAdapter object which registered to receive such events using the component's addKeyListener method. (KeyAdapter objects implement the KeyListener interface.) Each such listener object gets this KeyEvent when the event occurs.

"Key typed" events are higher-level and generally do not depend on the platform or keyboard layout. They are generated when a Unicode character is entered, and are the preferred way to find out about character input. In the simplest case, a key typed event is produced by a single key press (e.g., 'a'). Often, however, characters are produced by series of key presses (e.g., 'shift' + 'a'), and the mapping from key pressed events to key typed events may be many-to-one or many-to-many. Key releases are not usually necessary to generate a key typed event, but there are some cases where the key typed event is not generated until a key is released (e.g., entering ASCII sequences via the Alt-Numpad method in Windows). No key typed events are generated for keys that don't generate Unicode characters (e.g., action keys, modifier keys, etc.). The getKeyChar method always returns a valid Unicode character or CHAR_UNDEFINED. For key pressed and key released events, the getKeyCode method returns the event's keyCode. For key typed events, the getKeyCode method always returns VK_UNDEFINED.

"Key pressed" and "key released" events are lower-level and depend on the platform and keyboard layout. They are generated whenever a key is pressed or released, and are the only way to find out about keys that don't generate character input (e.g., action keys, modifier keys, etc.). The key being pressed or released is indicated by the getKeyCode method, which returns a virtual key code.

Virtual key codes are used to report which keyboard key has been pressed, rather than a character generated by the combination of one or more keystrokes (such as "A", which comes from shift and "a").

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. Separately, a KEY_TYPED event with a keyChar value of 'A' is generated.

Notes:

WARNING: Aside from those keys that are defined by the Java language (VK_ENTER, VK_BACK_SPACE, and VK_TAB), do not rely on the values of the VK_ constants. Sun reserves the right to change these values as needed to accomodate a wider range of keyboards in the future.

Author:
Carl Quinn

Amy Fowler

Norbert Lindenberg

Version:
1.65 01/23/03
See also:
KeyAdapter

KeyListener

Tutorial: Writing a Key Listener

Reference: The Java Class Libraries (update file)

Since:
1.1

Public Types

enum  KEY_EVENT_ID {
  KEY_FIRST = 400, KEY_TYPED = KEY_FIRST, KEY_PRESSED, KEY_RELEASED = 2 + KEY_FIRST,
  KEY_LAST = KEY_RELEASED
}
enum  KEY_LOCATION_ID {
  KEY_LOCATION_FIRST = 0, KEY_LOCATION_UNKNOWN = KEY_LOCATION_FIRST, KEY_LOCATION_STANDARD, KEY_LOCATION_LEFT,
  KEY_LOCATION_RIGHT, KEY_LOCATION_NUMPAD, KEY_LOCATION_LAST = KEY_LOCATION_NUMPAD
}
enum  VIRTUAL_KEY_CODES {
  JK_UNDEFINED = 0x00, JK_01, JK_02, JK_CANCEL,
  JK_04, JK_05, JK_06, JK_07,
  JK_BACK_SPACE = 0x08, JK_TAB = 0x09, JK_ENTER = 0x0A, JK_CLEAR = 0x0B,
  JK_0C, JK_0D, JK_0E, JK_0F,
  JK_SHIFT = 0x10, JK_CONTROL = 0x11, JK_ALT = 0x12, JK_PAUSE = 0x13,
  JK_CAPS_LOCK = 0x14, JK_KANA = 0x15, JK_16, JK_17,
  JK_FINAL = 0x18, JK_KANJI = 0x19, JK_1A, JK_ESCAPE = 0x1B,
  JK_CONVERT = 0x1C, JK_NONCONVERT = 0x1D, JK_ACCEPT = 0x1E, JK_MODECHANGE = 0x1F,
  JK_SPACE = 0x20, JK_PAGE_UP = 0x21, JK_PAGE_DOWN = 0x22, JK_END = 0x23,
  JK_HOME = 0x24, JK_LEFT = 0x25, JK_UP = 0x26, JK_RIGHT = 0x27,
  JK_DOWN = 0x28, JK_29, JK_2A, JK_2B,
  JK_COMMA = 0x2C, JK_MINUS = 0x2D, JK_PERIOD = 0x2E, JK_SLASH = 0x2F,
  JK_0 = 0x30, JK_1, JK_2, JK_3,
  JK_4, JK_5, JK_6, JK_7,
  JK_8, JK_9, JK_3A, JK_SEMICOLON = 0x3B,
  JK_3C, JK_EQUALS = 0x3D, JK_3E, JK_3F,
  JK_40, JK_A = 0x41, JK_B, JK_C,
  JK_D, JK_E, JK_F, JK_G,
  JK_H, JK_I, JK_J, JK_K,
  JK_L, JK_M, JK_N, JK_O,
  JK_P, JK_Q, JK_R, JK_S,
  JK_T, JK_U, JK_V, JK_W,
  JK_X, JK_Y, JK_Z, JK_OPEN_BRACKET = 0x5B,
  JK_BACK_SLASH = 0x5C, JK_CLOSE_BRACKET = 0x5D, JK_5E, JK_5F,
  JK_NUMPAD0 = 0x60, JK_NUMPAD1, JK_NUMPAD2, JK_NUMPAD3,
  JK_NUMPAD4, JK_NUMPAD5, JK_NUMPAD6, JK_NUMPAD7,
  JK_NUMPAD8, JK_NUMPAD9, JK_MULTIPLY = 0x6A, JK_ADD = 0x6B,
  JK_SEPARATOR = 0x6C, JK_SUBTRACT = 0x6D, JK_DECIMAL = 0x6E, JK_DIVIDE = 0x6F,
  JK_F1 = 0x70, JK_F2, JK_F3, JK_F4,
  JK_F5, JK_F6, JK_F7, JK_F8,
  JK_F9, JK_F10, JK_F11, JK_F12,
  JK_7C, JK_7D, JK_7E, JK_DELETE = 0x7F,
  JK_DEAD_GRAVE = 0x80, JK_DEAD_ACUTE, JK_DEAD_CIRCUMFLEX, JK_DEAD_TILDE,
  JK_DEAD_MACRON, JK_DEAD_BREVE, JK_DEAD_ABOVEDOT, JK_DEAD_DIAERESIS,
  JK_DEAD_ABOVERING, JK_DEAD_DOUBLEACUTE, JK_DEAD_CARON, JK_DEAD_CEDILLA,
  JK_DEAD_OGONEK, JK_DEAD_IOTA, JK_DEAD_VOICED_SOUND, JK_DEAD_SEMIVOICED_SOUND,
  JK_NUM_LOCK = 0x90, JK_SCROLL_LOCK = 0x91, JK_92, JK_93,
  JK_94, JK_95, JK_AMPERSAND = 0x96, JK_ASTERISK = 0x97,
  JK_QUOTEDBL = 0x98, JK_LESS = 0x99, JK_PRINTSCREEN = 0x9A, JK_INSERT = 0x9B,
  JK_HELP = 0x9C, JK_META = 0x9D, JK_9E, JK_9F,
  JK_GREATER = 0xA0, JK_BRACELEFT = 0xA1, JK_BRACERIGHT = 0xA2, JK_BACK_QUOTE = 0xC0,
  JK_QUOTE = 0xDE, JK_KP_UP = 0xE0, JK_KP_DOWN = 0xE1, JK_KP_LEFT = 0xE2,
  JK_KP_RIGHT = 0xE3, JK_ALPHANUMERIC = 0xF0, JK_KATAKANA = 0xF1, JK_HIRAGANA = 0xF2,
  JK_FULL_WIDTH = 0xF3, JK_HALF_WIDTH = 0xF4, JK_ROMAN_CHARACTERS = 0xF5, JK_ALL_CANDIDATES = 0x0100,
  JK_PREVIOUS_CANDIDATE = 0x0101, JK_CODE_INPUT = 0x0102, JK_JAPANESE_KATAKANA = 0x0103, JK_JAPANESE_HIRAGANA = 0x0104,
  JK_JAPANESE_ROMAN = 0x0105, JK_KANA_LOCK = 0x0106, JK_INPUT_METHOD_ON_OFF = 0x0107, JK_AT = 0x0200,
  JK_COLON, JK_CIRCUMFLEX, JK_DOLLAR, JK_EURO_SIGN,
  JK_EXCLAMATION_MARK, JK_INVERTED_EXCLAMATION_MARK, JK_LEFT_PARENTHESIS, JK_NUMBER_SIGN,
  JK_PLUS, JK_RIGHT_PARENTHESIS, JK_UNDERSCORE, JK_F13 = 0xF000,
  JK_F14, JK_F15, JK_F16, JK_F17,
  JK_F18, JK_F19, JK_F20, JK_F21,
  JK_F22, JK_F23, JK_F24, JK_COMPOSE = 0xFF20,
  JK_ALT_GRAPH = 0xFF7E, JK_STOP = 0xFFC8, JK_AGAIN = 0xFFC9, JK_PROPS = 0xFFCA,
  JK_UNDO = 0xFFCB, JK_FFCC = 0xFFCC, JK_COPY = 0xFFCD, JK_FFCE = 0xFFCE,
  JK_PASTE = 0xFFCF, JK_FIND = 0xFFD0, JK_CUT = 0xFFD1, CHAR_UNDEFINED = 0xFFFF
}

Public Member Functions

 KeyEvent ()
 KeyEvent (const Ref< Component > &source, jint id, jlong when, jint modifiers, jint keyCode, jchar keyChar, jint keyLocation=KEY_LOCATION_STANDARD)
 Constructs a KeyEvent object.
virtual void consume ()
 Consumes this event, if this event can be consumed.
virtual jint getKeyCode () const
 Returns the integer keyCode associated with the key in this event.
virtual void setKeyCode (jint keyCode)
 Set the keyCode value to indicate a physical key.
virtual jchar getKeyChar () const
 Returns the character associated with the key in this event.
virtual void setKeyChar (jchar keyChar)
 Set the keyChar value to indicate a logical character.
virtual jint getKeyLocation () const
 Returns the location of the key that originated this key event.
virtual jboolean isActionKey () const
 Returns whether the key in this event is an "action" key.
virtual String paramString () const
 Returns a parameter string identifying this event.

Static Public Member Functions

static String getKeyText (jint keyCode)
 Returns a String describing the keyCode, such as "HOME", "F1" or "A".

Protected Attributes

jint keyCode
 The unique value assigned to each of the keys on the keyboard.
jchar keyChar
 keyChar is a valid unicode character that is fired by a key or a key combination on a keyboard.
jint keyLocation
 The location of the key on the keyboard.

Member Enumeration Documentation

enum java::awt::event::KeyEvent::KEY_EVENT_ID

Enumerator:
KEY_FIRST  The first number in the range of ids used for key events.
KEY_TYPED  The "key typed" event.

This event is generated when a character is entered. In the simplest case, it is produced by a single key press. Often, however, characters are produced by series of key presses, and the mapping from key pressed events to key typed events may be many-to-one or many-to-many.

KEY_PRESSED  The "key pressed" event.

This event is generated when a key is pushed down.

KEY_RELEASED  The "key released" event.

This event is generated when a key is let up.

KEY_LAST  The last number in the range of ids used for key events.

enum java::awt::event::KeyEvent::KEY_LOCATION_ID

Enumerator:
KEY_LOCATION_FIRST 
KEY_LOCATION_UNKNOWN  A constant indicating that the keyLocation is indeterminate or not relevant.

KEY_TYPED events do not have a keyLocation; this value is used instead.

Since:
1.4
KEY_LOCATION_STANDARD  A constant indicating that the key pressed or released is not distinguished as the left or right version of a key, and did not originate on the numeric keypad (or did not originate with a virtual key corresponding to the numeric keypad).

Since:
1.4
KEY_LOCATION_LEFT  A constant indicating that the key pressed or released is in the left key location (there is more than one possible location for this key).

Example: the left shift key.

Since:
1.4
KEY_LOCATION_RIGHT  A constant indicating that the key pressed or released is in the right key location (there is more than one possible location for this key).

Example: the right shift key.

Since:
1.4
KEY_LOCATION_NUMPAD  A constant indicating that the key event originated on the numeric keypad or with a virtual key corresponding to the numeric keypad.

Since:
1.4
KEY_LOCATION_LAST 

enum java::awt::event::KeyEvent::VIRTUAL_KEY_CODES

Enumerator:
JK_UNDEFINED  This value is used to indicate that the keyCode is unknown.

KEY_TYPED events do not have a keyCode value; this value is used instead.

JK_01 
JK_02 
JK_CANCEL 
JK_04 
JK_05 
JK_06 
JK_07 
JK_BACK_SPACE 
JK_TAB 
JK_ENTER 
JK_CLEAR 
JK_0C 
JK_0D 
JK_0E 
JK_0F 
JK_SHIFT 
JK_CONTROL 
JK_ALT 
JK_PAUSE 
JK_CAPS_LOCK 
JK_KANA 
JK_16 
JK_17 
JK_FINAL 
JK_KANJI 
JK_1A 
JK_ESCAPE 
JK_CONVERT 
JK_NONCONVERT  Constant for the Don't Convert function key.

JK_ACCEPT  Constant for the Accept or Commit function key.

JK_MODECHANGE 
JK_SPACE 
JK_PAGE_UP 
JK_PAGE_DOWN 
JK_END 
JK_HOME 
JK_LEFT  Constant for the non-numpad left arrow key.

See also:
VK_KP_LEFT
JK_UP  Constant for the non-numpad up arrow key.

See also:
VK_KP_UP
JK_RIGHT  Constant for the non-numpad right arrow key.

See also:
VK_KP_RIGHT
JK_DOWN  Constant for the non-numpad down arrow key.

See also:
VK_KP_DOWN
JK_29 
JK_2A 
JK_2B 
JK_COMMA 
JK_MINUS  Constant for the "-" key.

Since:
1.2
JK_PERIOD 
JK_SLASH 
JK_0  VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39).
JK_1 
JK_2 
JK_3 
JK_4 
JK_5 
JK_6 
JK_7 
JK_8 
JK_9 
JK_3A 
JK_SEMICOLON 
JK_3C 
JK_EQUALS 
JK_3E 
JK_3F 
JK_40 
JK_A  VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A).
JK_B 
JK_C 
JK_D 
JK_E 
JK_F 
JK_G 
JK_H 
JK_I 
JK_J 
JK_K 
JK_L 
JK_M 
JK_N 
JK_O 
JK_P 
JK_Q 
JK_R 
JK_S 
JK_T 
JK_U 
JK_V 
JK_W 
JK_X 
JK_Y 
JK_Z 
JK_OPEN_BRACKET 
JK_BACK_SLASH 
JK_CLOSE_BRACKET 
JK_5E 
JK_5F 
JK_NUMPAD0 
JK_NUMPAD1 
JK_NUMPAD2 
JK_NUMPAD3 
JK_NUMPAD4 
JK_NUMPAD5 
JK_NUMPAD6 
JK_NUMPAD7 
JK_NUMPAD8 
JK_NUMPAD9 
JK_MULTIPLY 
JK_ADD 
JK_SEPARATOR  Constant for the Numpad Separator key.

Since:
1.4
JK_SUBTRACT 
JK_DECIMAL 
JK_DIVIDE 
JK_F1  Constant for the F1 function key.

JK_F2  Constant for the F2 function key.

JK_F3  Constant for the F3 function key.

JK_F4  Constant for the F4 function key.

JK_F5  Constant for the F5 function key.

JK_F6  Constant for the F6 function key.

JK_F7  Constant for the F7 function key.

JK_F8  Constant for the F8 function key.

JK_F9  Constant for the F9 function key.

JK_F10  Constant for the F10 function key.

JK_F11  Constant for the F11 function key.

JK_F12  Constant for the F12 function key.

JK_7C 
JK_7D 
JK_7E 
JK_DELETE 
JK_DEAD_GRAVE 
Since:
1.2
JK_DEAD_ACUTE 
Since:
1.2
JK_DEAD_CIRCUMFLEX 
Since:
1.2
JK_DEAD_TILDE 
Since:
1.2
JK_DEAD_MACRON 
Since:
1.2
JK_DEAD_BREVE 
Since:
1.2
JK_DEAD_ABOVEDOT 
Since:
1.2
JK_DEAD_DIAERESIS 
Since:
1.2
JK_DEAD_ABOVERING 
Since:
1.2
JK_DEAD_DOUBLEACUTE 
Since:
1.2
JK_DEAD_CARON 
Since:
1.2
JK_DEAD_CEDILLA 
Since:
1.2
JK_DEAD_OGONEK 
Since:
1.2
JK_DEAD_IOTA 
Since:
1.2
JK_DEAD_VOICED_SOUND 
Since:
1.2
JK_DEAD_SEMIVOICED_SOUND 
Since:
1.2
JK_NUM_LOCK 
JK_SCROLL_LOCK 
JK_92 
JK_93 
JK_94 
JK_95 
JK_AMPERSAND 
Since:
1.2
JK_ASTERISK 
Since:
1.2
JK_QUOTEDBL 
Since:
1.2
JK_LESS 
Since:
1.2
JK_PRINTSCREEN 
JK_INSERT 
JK_HELP 
JK_META 
JK_9E 
JK_9F 
JK_GREATER 
Since:
1.2
JK_BRACELEFT 
Since:
1.2
JK_BRACERIGHT 
Since:
1.2
JK_BACK_QUOTE 
JK_QUOTE 
JK_KP_UP  Constant for the numeric keypad up arrow key.

See also:
VK_UP
Since:
1.2
JK_KP_DOWN  Constant for the numeric keypad down arrow key.

See also:
VK_DOWN
Since:
1.2
JK_KP_LEFT  Constant for the numeric keypad left arrow key.

See also:
VK_LEFT
Since:
1.2
JK_KP_RIGHT  Constant for the numeric keypad right arrow key.

See also:
VK_RIGHT
Since:
1.2
JK_ALPHANUMERIC  Constant for the Alphanumeric function key.

Since:
1.2
JK_KATAKANA  Constant for the Katakana function key.

Since:
1.2
JK_HIRAGANA  Constant for the Hiragana function key.

Since:
1.2
JK_FULL_WIDTH  Constant for the Full-Width Characters function key.

Since:
1.2
JK_HALF_WIDTH  Constant for the Half-Width Characters function key.

Since:
1.2
JK_ROMAN_CHARACTERS  Constant for the Roman Characters function key.

Since:
1.2
JK_ALL_CANDIDATES  Constant for the All Candidates function key.

Since:
1.2
JK_PREVIOUS_CANDIDATE  Constant for the Previous Candidate function key.

Since:
1.2
JK_CODE_INPUT  Constant for the Code Input function key.

Since:
1.2
JK_JAPANESE_KATAKANA  Constant for the Japanese-Katakana function key.

This key switches to a Japanese input method and selects its Katakana input mode.

Since:
1.2
JK_JAPANESE_HIRAGANA  Constant for the Japanese-Hiragana function key.

This key switches to a Japanese input method and selects its Hiragana input mode.

Since:
1.2
JK_JAPANESE_ROMAN  Constant for the Japanese-Roman function key.

This key switches to a Japanese input method and selects its Roman-Direct input mode.

Since:
1.2
JK_KANA_LOCK  Constant for the locking Kana function key.

This key locks the keyboard into a Kana layout.

Since:
1.3
JK_INPUT_METHOD_ON_OFF  Constant for the input method on/off key.

Since:
1.3
JK_AT  Constant for the "@" key.

Since:
1.2
JK_COLON  Constant for the ":" key.

Since:
1.2
JK_CIRCUMFLEX  Constant for the "^" key.

Since:
1.2
JK_DOLLAR  Constant for the "$" key.

Since:
1.2
JK_EURO_SIGN  Constant for the Euro currency sign key.

Since:
1.2
JK_EXCLAMATION_MARK  Constant for the "!" key.

Since:
1.2
JK_INVERTED_EXCLAMATION_MARK  Constant for the inverted exclamation mark key.

Since:
1.2
JK_LEFT_PARENTHESIS  Constant for the "(" key.

Since:
1.2
JK_NUMBER_SIGN  Constant for the "#" key.

Since:
1.2
JK_PLUS  Constant for the "+" key.

Since:
1.2
JK_RIGHT_PARENTHESIS  Constant for the ")" key.

Since:
1.2
JK_UNDERSCORE  Constant for the "_" key.

Since:
1.2
JK_F13  Constant for the F13 function key.

Since:
1.2
JK_F14  Constant for the F14 function key.

Since:
1.2
JK_F15  Constant for the F15 function key.

Since:
1.2
JK_F16  Constant for the F16 function key.

Since:
1.2
JK_F17  Constant for the F17 function key.

Since:
1.2
JK_F18  Constant for the F18 function key.

Since:
1.2
JK_F19  Constant for the F19 function key.

Since:
1.2
JK_F20  Constant for the F20 function key.

Since:
1.2
JK_F21  Constant for the F21 function key.

Since:
1.2
JK_F22  Constant for the F22 function key.

Since:
1.2
JK_F23  Constant for the F23 function key.

Since:
1.2
JK_F24  Constant for the F24 function key.

Since:
1.2
JK_COMPOSE  Constant for the Compose function key.

Since:
1.2
JK_ALT_GRAPH  Constant for the AltGraph function key.

Since:
1.2
JK_STOP 
JK_AGAIN 
JK_PROPS 
JK_UNDO 
JK_FFCC 
JK_COPY 
JK_FFCE 
JK_PASTE 
JK_FIND 
JK_CUT 
CHAR_UNDEFINED  KEY_PRESSED and KEY_RELEASED events which do not map to a valid Unicode character use this for the keyChar value.


Constructor & Destructor Documentation

java::awt::event::KeyEvent::KeyEvent (  ) 

java::awt::event::KeyEvent::KeyEvent ( const Ref< Component > &  source,
jint  id,
jlong  when,
jint  modifiers,
jint  keyCode,
jchar  keyChar,
jint  keyLocation = KEY_LOCATION_STANDARD 
)

Constructs a KeyEvent object.

Note that passing in an invalid id results in unspecified behavior.

Parameters:
source the Component that originated the event
id an integer identifying the type of event
when a long integer that specifies the time the event occurred
modifiers the modifier keys down during event (shift, ctrl, alt, meta) Either extended _DOWN_MASK or old _MASK modifiers should be used, but both models should not be mixed in one event. Use of the extended modifiers is preferred.
keyCode the integer code for an actual key, or VK_UNDEFINED (for a key-typed event)
keyChar the Unicode character generated by this event, or CHAR_UNDEFINED (for key-pressed and key-released events which do not map to a valid Unicode character)
keyLocation identifies the key location. The only legal values are KEY_LOCATION_UNKNOWN, KEY_LOCATION_STANDARD, KEY_LOCATION_LEFT, KEY_LOCATION_RIGHT, and KEY_LOCATION_NUMPAD.
Exceptions:
IllegalArgumentException if id is KEY_TYPED and keyChar is CHAR_UNDEFINED; or if id is KEY_TYPED and keyCode is not VK_UNDEFINED; or if id is KEY_TYPED and keyLocation is not KEY_LOCATION_UNKNOWN; or if keyLocation is not one of the legal values enumerated above.
Since:
1.4


Member Function Documentation

virtual void java::awt::event::KeyEvent::consume (  )  [virtual]

Consumes this event, if this event can be consumed.

Only low-level, system events can be consumed

Reimplemented from java::awt::event::InputEvent.

virtual jint java::awt::event::KeyEvent::getKeyCode (  )  const [virtual]

Returns the integer keyCode associated with the key in this event.

Returns:
the integer code for an actual key on the keyboard. (For KEY_TYPED events, the keyCode is VK_UNDEFINED.)

virtual void java::awt::event::KeyEvent::setKeyCode ( jint  keyCode  )  [virtual]

Set the keyCode value to indicate a physical key.

Parameters:
keyCode an integer corresponding to an actual key on the keyboard.

virtual jchar java::awt::event::KeyEvent::getKeyChar (  )  const [virtual]

Returns the character associated with the key in this event.

For example, the key-typed event for shift + "a" returns the value for "A".

Returns:
the Unicode character defined for this key event. If no valid Unicode character exists for this key event, keyChar is CHAR_UNDEFINED.

virtual void java::awt::event::KeyEvent::setKeyChar ( jchar  keyChar  )  [virtual]

Set the keyChar value to indicate a logical character.

Parameters:
keyChar a char corresponding to to the combination of keystrokes that make up this event.

virtual jint java::awt::event::KeyEvent::getKeyLocation (  )  const [virtual]

Returns the location of the key that originated this key event.

Some keys occur more than once on a keyboard, e.g. the left and right shift keys. Additionally, some keys occur on the numeric keypad. This provides a way of distinguishing such keys.

Returns:
the location of the key that was pressed or released. Always returns KEY_LOCATION_UNKNOWN for KEY_TYPED events.
Since:
1.4

static String java::awt::event::KeyEvent::getKeyText ( jint  keyCode  )  [static]

Returns a String describing the keyCode, such as "HOME", "F1" or "A".

These strings can be localized by changing the awt.properties file.

Returns:
a string containing a text description for a physical key, identified by its keyCode

virtual jboolean java::awt::event::KeyEvent::isActionKey (  )  const [virtual]

Returns whether the key in this event is an "action" key.

Typically an action key does not fire a unicode character and is not a modifier key.

Returns:
true if the key is an "action" key, false otherwise

virtual String java::awt::event::KeyEvent::paramString (  )  const [virtual]

Returns a parameter string identifying this event.

This method is useful for event-logging and for debugging.

Returns:
a string identifying the event and its attributes

Reimplemented from java::awt::event::ComponentEvent.


Member Data Documentation

jint java::awt::event::KeyEvent::keyCode [protected]

The unique value assigned to each of the keys on the keyboard.

There is a common set of key codes that can be fired by most keyboards. The symbolic name for a key code should be used rather than the code value itself.

See also:
getKeyCode()

setKeyCode(int)

jchar java::awt::event::KeyEvent::keyChar [protected]

keyChar is a valid unicode character that is fired by a key or a key combination on a keyboard.

See also:
getKeyChar()

setKeyChar(char)

jint java::awt::event::KeyEvent::keyLocation [protected]

The location of the key on the keyboard.

Some keys occur more than once on a keyboard, e.g. the left and right shift keys. Additionally, some keys occur on the numeric keypad. This variable is used to distinguish such keys.

The only legal values are KEY_LOCATION_UNKNOWN, KEY_LOCATION_STANDARD, KEY_LOCATION_LEFT, KEY_LOCATION_RIGHT, and KEY_LOCATION_NUMPAD.

See also:
getKeyLocation()


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:17 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3