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.


Variable Index

 o CHAR_UNDEFINED
KEY_PRESSED and KEY_RELEASED events which do not map to a valid Unicode character do not have a defined keyChar.
 o KEY_FIRST
Marks the first integer id for the range of key event ids.
 o KEY_LAST
Marks the last integer id for the range of key event ids.
 o KEY_PRESSED
The key pressed event type.
 o KEY_RELEASED
The key released event type.
 o KEY_TYPED
The key typed event type.
 o VK_0
VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39)
 o VK_1
 o VK_2
 o VK_3
 o VK_4
 o VK_5
 o VK_6
 o VK_7
 o VK_8
 o VK_9
 o VK_A
VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A)
 o VK_ACCEPT
 o VK_ADD
 o VK_ALT
 o VK_B
 o VK_BACK_QUOTE
 o VK_BACK_SLASH
 o VK_BACK_SPACE
 o VK_C
 o VK_CANCEL
 o VK_CAPS_LOCK
 o VK_CLEAR
 o VK_CLOSE_BRACKET
 o VK_COMMA
 o VK_CONTROL
 o VK_CONVERT
 o VK_D
 o VK_DECIMAL
 o VK_DELETE
 o VK_DIVIDE
 o VK_DOWN
 o VK_E
 o VK_END
 o VK_ENTER
Virtual key codes.
 o VK_EQUALS
 o VK_ESCAPE
 o VK_F
 o VK_F1
 o VK_F10
 o VK_F11
 o VK_F12
 o VK_F2
 o VK_F3
 o VK_F4
 o VK_F5
 o VK_F6
 o VK_F7
 o VK_F8
 o VK_F9
 o VK_FINAL
for Asian Keyboard
 o VK_G
 o VK_H
 o VK_HELP
 o VK_HOME
 o VK_I
 o VK_INSERT
 o VK_J
 o VK_K
 o VK_KANA
 o VK_KANJI
 o VK_L
 o VK_LEFT
 o VK_M
 o VK_META
 o VK_MODECHANGE
 o VK_MULTIPLY
 o VK_N
 o VK_NONCONVERT
 o VK_NUM_LOCK
 o VK_NUMPAD0
 o VK_NUMPAD1
 o VK_NUMPAD2
 o VK_NUMPAD3
 o VK_NUMPAD4
 o VK_NUMPAD5
 o VK_NUMPAD6
 o VK_NUMPAD7
 o VK_NUMPAD8
 o VK_NUMPAD9
 o VK_O
 o VK_OPEN_BRACKET
 o VK_P
 o VK_PAGE_DOWN
 o VK_PAGE_UP
 o VK_PAUSE
 o VK_PERIOD
 o VK_PRINTSCREEN
 o VK_Q
 o VK_QUOTE
 o VK_R
 o VK_RIGHT
 o VK_S
 o VK_SCROLL_LOCK
 o VK_SEMICOLON
 o VK_SEPARATER
 o VK_SHIFT
 o VK_SLASH
 o VK_SPACE
 o VK_SUBTRACT
 o VK_T
 o VK_TAB
 o VK_U
 o VK_UNDEFINED
KEY_TYPED events do not have a defined keyCode.
 o VK_UP
 o VK_V
 o VK_W
 o VK_X
 o VK_Y
 o VK_Z

Constructor Index

 o KeyEvent(Component, int, long, int, int)
 o KeyEvent(Component, int, long, int, int, char)
Constructs a KeyEvent object with the specified source component, type, modifiers, and key.

Method Index

 o getKeyChar()
Returns the character associated with the key in this event.
 o getKeyCode()
Returns the integer key-code associated with the key in this event.
 o getKeyModifiersText(int)
Returns a String describing the modifier key(s), such as "Shift", or "Ctrl+Shift".
 o getKeyText(int)
Returns a String describing the keyCode, such as "HOME", "F1" or "A".
 o isActionKey()
Returns whether or not the key in this event is an "action" key.
 o paramString()
 o setKeyChar(char)
 o setKeyCode(int)
 o setModifiers(int)

Variables

 o KEY_FIRST
Properties Public Constant 
   KEY_FIRST=int 
Marks the first integer id for the range of key event ids.

 o KEY_LAST
Properties Public Constant 
   KEY_LAST=int 
Marks the last integer id for the range of key event ids.

 o 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.

 o KEY_PRESSED
Properties Public Constant 
   KEY_PRESSED=int 
The key pressed event type.

 o KEY_RELEASED
Properties Public Constant 
   KEY_RELEASED=int 
The key released event type.

 o 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.

 o VK_BACK_SPACE
Properties Public Constant 
   VK_BACK_SPACE=int 
 o VK_TAB
Properties Public Constant 
   VK_TAB=int 
 o VK_CANCEL
Properties Public Constant 
   VK_CANCEL=int 
 o VK_CLEAR
Properties Public Constant 
   VK_CLEAR=int 
 o VK_SHIFT
Properties Public Constant 
   VK_SHIFT=int 
 o VK_CONTROL
Properties Public Constant 
   VK_CONTROL=int 
 o VK_ALT
Properties Public Constant 
   VK_ALT=int 
 o VK_PAUSE
Properties Public Constant 
   VK_PAUSE=int 
 o VK_CAPS_LOCK
Properties Public Constant 
   VK_CAPS_LOCK=int 
 o VK_ESCAPE
Properties Public Constant 
   VK_ESCAPE=int 
 o VK_SPACE
Properties Public Constant 
   VK_SPACE=int 
 o VK_PAGE_UP
Properties Public Constant 
   VK_PAGE_UP=int 
 o VK_PAGE_DOWN
Properties Public Constant 
   VK_PAGE_DOWN=int 
 o VK_END
Properties Public Constant 
   VK_END=int 
 o VK_HOME
Properties Public Constant 
   VK_HOME=int 
 o VK_LEFT
Properties Public Constant 
   VK_LEFT=int 
 o VK_UP
Properties Public Constant 
   VK_UP=int 
 o VK_RIGHT
Properties Public Constant 
   VK_RIGHT=int 
 o VK_DOWN
Properties Public Constant 
   VK_DOWN=int 
 o VK_COMMA
Properties Public Constant 
   VK_COMMA=int 
 o VK_PERIOD
Properties Public Constant 
   VK_PERIOD=int 
 o VK_SLASH
Properties Public Constant 
   VK_SLASH=int 
 o VK_0
Properties Public Constant 
   VK_0=int 
VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39)

 o VK_1
Properties Public Constant 
   VK_1=int 
 o VK_2
Properties Public Constant 
   VK_2=int 
 o VK_3
Properties Public Constant 
   VK_3=int 
 o VK_4
Properties Public Constant 
   VK_4=int 
 o VK_5
Properties Public Constant 
   VK_5=int 
 o VK_6
Properties Public Constant 
   VK_6=int 
 o VK_7
Properties Public Constant 
   VK_7=int 
 o VK_8
Properties Public Constant 
   VK_8=int 
 o VK_9
Properties Public Constant 
   VK_9=int 
 o VK_SEMICOLON
Properties Public Constant 
   VK_SEMICOLON=int 
 o VK_EQUALS
Properties Public Constant 
   VK_EQUALS=int 
 o VK_A
Properties Public Constant 
   VK_A=int 
VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A)

 o VK_B
Properties Public Constant 
   VK_B=int 
 o VK_C
Properties Public Constant 
   VK_C=int 
 o VK_D
Properties Public Constant 
   VK_D=int 
 o VK_E
Properties Public Constant 
   VK_E=int 
 o VK_F
Properties Public Constant 
   VK_F=int 
 o VK_G
Properties Public Constant 
   VK_G=int 
 o VK_H
Properties Public Constant 
   VK_H=int 
 o VK_I
Properties Public Constant 
   VK_I=int 
 o VK_J
Properties Public Constant 
   VK_J=int 
 o VK_K
Properties Public Constant 
   VK_K=int 
 o VK_L
Properties Public Constant 
   VK_L=int 
 o VK_M
Properties Public Constant 
   VK_M=int 
 o VK_N
Properties Public Constant 
   VK_N=int 
 o VK_O
Properties Public Constant 
   VK_O=int 
 o VK_P
Properties Public Constant 
   VK_P=int 
 o VK_Q
Properties Public Constant 
   VK_Q=int 
 o VK_R
Properties Public Constant 
   VK_R=int 
 o VK_S
Properties Public Constant 
   VK_S=int 
 o VK_T
Properties Public Constant 
   VK_T=int 
 o VK_U
Properties Public Constant 
   VK_U=int 
 o VK_V
Properties Public Constant 
   VK_V=int 
 o VK_W
Properties Public Constant 
   VK_W=int 
 o VK_X
Properties Public Constant 
   VK_X=int 
 o VK_Y
Properties Public Constant 
   VK_Y=int 
 o VK_Z
Properties Public Constant 
   VK_Z=int 
 o VK_OPEN_BRACKET
Properties Public Constant 
   VK_OPEN_BRACKET=int 
 o VK_BACK_SLASH
Properties Public Constant 
   VK_BACK_SLASH=int 
 o VK_CLOSE_BRACKET
Properties Public Constant 
   VK_CLOSE_BRACKET=int 
 o VK_NUMPAD0
Properties Public Constant 
   VK_NUMPAD0=int 
 o VK_NUMPAD1
Properties Public Constant 
   VK_NUMPAD1=int 
 o VK_NUMPAD2
Properties Public Constant 
   VK_NUMPAD2=int 
 o VK_NUMPAD3
Properties Public Constant 
   VK_NUMPAD3=int 
 o VK_NUMPAD4
Properties Public Constant 
   VK_NUMPAD4=int 
 o VK_NUMPAD5
Properties Public Constant 
   VK_NUMPAD5=int 
 o VK_NUMPAD6
Properties Public Constant 
   VK_NUMPAD6=int 
 o VK_NUMPAD7
Properties Public Constant 
   VK_NUMPAD7=int 
 o VK_NUMPAD8
Properties Public Constant 
   VK_NUMPAD8=int 
 o VK_NUMPAD9
Properties Public Constant 
   VK_NUMPAD9=int 
 o VK_MULTIPLY
Properties Public Constant 
   VK_MULTIPLY=int 
 o VK_ADD
Properties Public Constant 
   VK_ADD=int 
 o VK_SEPARATER
Properties Public Constant 
   VK_SEPARATER=int 
 o VK_SUBTRACT
Properties Public Constant 
   VK_SUBTRACT=int 
 o VK_DECIMAL
Properties Public Constant 
   VK_DECIMAL=int 
 o VK_DIVIDE
Properties Public Constant 
   VK_DIVIDE=int 
 o VK_F1
Properties Public Constant 
   VK_F1=int 
 o VK_F2
Properties Public Constant 
   VK_F2=int 
 o VK_F3
Properties Public Constant 
   VK_F3=int 
 o VK_F4
Properties Public Constant 
   VK_F4=int 
 o VK_F5
Properties Public Constant 
   VK_F5=int 
 o VK_F6
Properties Public Constant 
   VK_F6=int 
 o VK_F7
Properties Public Constant 
   VK_F7=int 
 o VK_F8
Properties Public Constant 
   VK_F8=int 
 o VK_F9
Properties Public Constant 
   VK_F9=int 
 o VK_F10
Properties Public Constant 
   VK_F10=int 
 o VK_F11
Properties Public Constant 
   VK_F11=int 
 o VK_F12
Properties Public Constant 
   VK_F12=int 
 o VK_DELETE
Properties Public Constant 
   VK_DELETE=int 
 o VK_NUM_LOCK
Properties Public Constant 
   VK_NUM_LOCK=int 
 o VK_SCROLL_LOCK
Properties Public Constant 
   VK_SCROLL_LOCK=int 
 o VK_PRINTSCREEN
Properties Public Constant 
   VK_PRINTSCREEN=int 
 o VK_INSERT
Properties Public Constant 
   VK_INSERT=int 
 o VK_HELP
Properties Public Constant 
   VK_HELP=int 
 o VK_META
Properties Public Constant 
   VK_META=int 
 o VK_BACK_QUOTE
Properties Public Constant 
   VK_BACK_QUOTE=int 
 o VK_QUOTE
Properties Public Constant 
   VK_QUOTE=int 
 o VK_FINAL
Properties Public Constant 
   VK_FINAL=int 
for Asian Keyboard

 o VK_CONVERT
Properties Public Constant 
   VK_CONVERT=int 
 o VK_NONCONVERT
Properties Public Constant 
   VK_NONCONVERT=int 
 o VK_ACCEPT
Properties Public Constant 
   VK_ACCEPT=int 
 o VK_MODECHANGE
Properties Public Constant 
   VK_MODECHANGE=int 
 o VK_KANA
Properties Public Constant 
   VK_KANA=int 
 o VK_KANJI
Properties Public Constant 
   VK_KANJI=int 
 o VK_UNDEFINED
Properties Public Constant 
   VK_UNDEFINED=int 
KEY_TYPED events do not have a defined keyCode.

 o 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.

Constructors

 o 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
 o KeyEvent
    method KeyEvent(source=Component, -
                    id=int, -
                    when=long, -
                    modifiers=int, -
                    keyCode=int) public 

Methods

 o 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.

 o setKeyCode
    method setKeyCode(keyCode=int)  public     
 o setKeyChar
    method setKeyChar(keyChar=char)  public     
 o setModifiers
    method setModifiers(modifiers=int)  public     
 o 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.

 o 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.

 o 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.

 o isActionKey
    method isActionKey() returns boolean public     
Returns whether or not the key in this event is an "action" key.

 o paramString
    method paramString() returns String public     
Overrides:
paramString in class ComponentEvent

All Packages  Class Hierarchy  This Package  Previous  Next  Index