Java Doc for KeyEvent.java in  » 6.0-JDK-Core » AWT » java » awt » event » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt.event 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.awt.event.ComponentEvent
   java.awt.event.InputEvent
      java.awt.event.KeyEvent

KeyEvent
public class KeyEvent extends InputEvent (Code)
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. Character input is reported by KEY_TYPED events: KEY_PRESSED and KEY_RELEASED events are not necessarily associated with character input. Therefore, the result of the getKeyChar method is guaranteed to be meaningful only for KEY_TYPED events.

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.

Pressing and releasing a key on the keyboard results in the generating the following key events (in order):

  KEY_PRESSED   KEY_TYPED   (is only generated if a valid Unicode character could be generated.)
  KEY_RELEASED  
But in some cases (e.g. auto-repeat or input method is activated) the order could be different (and platform dependent).

Notes:

  • Key combinations which do not result in Unicode characters, such as action keys like F1 and the HELP key, do not generate KEY_TYPED events.
  • Not all keyboards or systems are capable of generating all virtual key codes. No attempt is made in Java to generate these keys artificially.
  • Virtual key codes do not identify a physical key: they depend on the platform and keyboard layout. For example, the key that generates VK_Q when using a U.S. keyboard layout will generate VK_A when using a French keyboard layout.
  • Not all characters have a keycode associated with them. For example, there is no keycode for the question mark because there is no keyboard for which it appears on the primary layer.
  • In order to support the platform-independent handling of action keys, the Java platform uses a few additional virtual key constants for functions that would otherwise have to be recognized by interpreting virtual key codes and modifiers. For example, for Japanese Windows keyboards, VK_ALL_CANDIDATES is returned instead of VK_CONVERT with the ALT modifier.
  • As specified in Focus Specification key events are dispatched to the focus owner by default.

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
author:
   Amy Fowler
author:
   Norbert Lindenberg
version:
   1.88 05/05/07
See Also:   KeyAdapter
See Also:   KeyListener
See Also:    Tutorial: Writing a Key Listener
since:
   1.1



Field Summary
final public static  charCHAR_UNDEFINED
     KEY_PRESSED and KEY_RELEASED events which do not map to a valid Unicode character use this for the keyChar value.
final public static  intKEY_FIRST
     The first number in the range of ids used for key events.
final public static  intKEY_LAST
     The last number in the range of ids used for key events.
final public static  intKEY_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).
final public static  intKEY_LOCATION_NUMPAD
     A constant indicating that the key event originated on the numeric keypad or with a virtual key corresponding to the numeric keypad.
final public static  intKEY_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).
final public static  intKEY_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).
final public static  intKEY_LOCATION_UNKNOWN
     A constant indicating that the keyLocation is indeterminate or not relevant.
final public static  intKEY_PRESSED
     The "key pressed" event.
final public static  intKEY_RELEASED
     The "key released" event.
final public static  intKEY_TYPED
     The "key typed" event.
final public static  intVK_0
    
final public static  intVK_1
    
final public static  intVK_2
    
final public static  intVK_3
    
final public static  intVK_4
    
final public static  intVK_5
    
final public static  intVK_6
    
final public static  intVK_7
    
final public static  intVK_8
    
final public static  intVK_9
    
final public static  intVK_A
    
final public static  intVK_ACCEPT
     Constant for the Accept or Commit function key.
final public static  intVK_ADD
    
final public static  intVK_AGAIN
    
final public static  intVK_ALL_CANDIDATES
     Constant for the All Candidates function key.
final public static  intVK_ALPHANUMERIC
     Constant for the Alphanumeric function key.
final public static  intVK_ALT
    
final public static  intVK_ALT_GRAPH
     Constant for the AltGraph function key.
final public static  intVK_AMPERSAND
    
final public static  intVK_ASTERISK
    
final public static  intVK_AT
     Constant for the "@" key.
final public static  intVK_B
    
final public static  intVK_BACK_QUOTE
    
final public static  intVK_BACK_SLASH
    
final public static  intVK_BACK_SPACE
    
final public static  intVK_BEGIN
     Constant for the Begin key.
final public static  intVK_BRACELEFT
    
final public static  intVK_BRACERIGHT
    
final public static  intVK_C
    
final public static  intVK_CANCEL
    
final public static  intVK_CAPS_LOCK
    
final public static  intVK_CIRCUMFLEX
     Constant for the "^" key.
final public static  intVK_CLEAR
    
final public static  intVK_CLOSE_BRACKET
    
final public static  intVK_CODE_INPUT
     Constant for the Code Input function key.
final public static  intVK_COLON
     Constant for the ":" key.
final public static  intVK_COMMA
    
final public static  intVK_COMPOSE
     Constant for the Compose function key.
final public static  intVK_CONTEXT_MENU
     Constant for the Microsoft Windows Context Menu key.
final public static  intVK_CONTROL
    
final public static  intVK_CONVERT
     Constant for the Convert function key.
final public static  intVK_COPY
    
final public static  intVK_CUT
    
final public static  intVK_D
    
final public static  intVK_DEAD_ABOVEDOT
    
final public static  intVK_DEAD_ABOVERING
    
final public static  intVK_DEAD_ACUTE
    
final public static  intVK_DEAD_BREVE
    
final public static  intVK_DEAD_CARON
    
final public static  intVK_DEAD_CEDILLA
    
final public static  intVK_DEAD_CIRCUMFLEX
    
final public static  intVK_DEAD_DIAERESIS
    
final public static  intVK_DEAD_DOUBLEACUTE
    
final public static  intVK_DEAD_GRAVE
    
final public static  intVK_DEAD_IOTA
    
final public static  intVK_DEAD_MACRON
    
final public static  intVK_DEAD_OGONEK
    
final public static  intVK_DEAD_SEMIVOICED_SOUND
    
final public static  intVK_DEAD_TILDE
    
final public static  intVK_DEAD_VOICED_SOUND
    
final public static  intVK_DECIMAL
    
final public static  intVK_DELETE
    
final public static  intVK_DIVIDE
    
final public static  intVK_DOLLAR
     Constant for the "$" key.
final public static  intVK_DOWN
     Constant for the non-numpad down arrow key.
final public static  intVK_E
    
final public static  intVK_END
    
final public static  intVK_ENTER
    
final public static  intVK_EQUALS
    
final public static  intVK_ESCAPE
    
final public static  intVK_EURO_SIGN
     Constant for the Euro currency sign key.
final public static  intVK_EXCLAMATION_MARK
     Constant for the "!" key.
final public static  intVK_F
    
final public static  intVK_F1
     Constant for the F1 function key.
final public static  intVK_F10
     Constant for the F10 function key.
final public static  intVK_F11
     Constant for the F11 function key.
final public static  intVK_F12
     Constant for the F12 function key.
final public static  intVK_F13
     Constant for the F13 function key.
final public static  intVK_F14
     Constant for the F14 function key.
final public static  intVK_F15
     Constant for the F15 function key.
final public static  intVK_F16
     Constant for the F16 function key.
final public static  intVK_F17
     Constant for the F17 function key.
final public static  intVK_F18
     Constant for the F18 function key.
final public static  intVK_F19
     Constant for the F19 function key.
final public static  intVK_F2
     Constant for the F2 function key.
final public static  intVK_F20
     Constant for the F20 function key.
final public static  intVK_F21
     Constant for the F21 function key.
final public static  intVK_F22
     Constant for the F22 function key.
final public static  intVK_F23
     Constant for the F23 function key.
final public static  intVK_F24
     Constant for the F24 function key.
final public static  intVK_F3
     Constant for the F3 function key.
final public static  intVK_F4
     Constant for the F4 function key.
final public static  intVK_F5
     Constant for the F5 function key.
final public static  intVK_F6
     Constant for the F6 function key.
final public static  intVK_F7
     Constant for the F7 function key.
final public static  intVK_F8
     Constant for the F8 function key.
final public static  intVK_F9
     Constant for the F9 function key.
final public static  intVK_FINAL
    
final public static  intVK_FIND
    
final public static  intVK_FULL_WIDTH
     Constant for the Full-Width Characters function key.
final public static  intVK_G
    
final public static  intVK_GREATER
    
final public static  intVK_H
    
final public static  intVK_HALF_WIDTH
     Constant for the Half-Width Characters function key.
final public static  intVK_HELP
    
final public static  intVK_HIRAGANA
     Constant for the Hiragana function key.
final public static  intVK_HOME
    
final public static  intVK_I
    
final public static  intVK_INPUT_METHOD_ON_OFF
     Constant for the input method on/off key.
final public static  intVK_INSERT
    
final public static  intVK_INVERTED_EXCLAMATION_MARK
     Constant for the inverted exclamation mark key.
final public static  intVK_J
    
final public static  intVK_JAPANESE_HIRAGANA
     Constant for the Japanese-Hiragana function key.
final public static  intVK_JAPANESE_KATAKANA
     Constant for the Japanese-Katakana function key.
final public static  intVK_JAPANESE_ROMAN
     Constant for the Japanese-Roman function key.
final public static  intVK_K
    
final public static  intVK_KANA
    
final public static  intVK_KANA_LOCK
     Constant for the locking Kana function key.
final public static  intVK_KANJI
    
final public static  intVK_KATAKANA
     Constant for the Katakana function key.
final public static  intVK_KP_DOWN
     Constant for the numeric keypad down arrow key.
final public static  intVK_KP_LEFT
     Constant for the numeric keypad left arrow key.
final public static  intVK_KP_RIGHT
     Constant for the numeric keypad right arrow key.
final public static  intVK_KP_UP
     Constant for the numeric keypad up arrow key.
final public static  intVK_L
    
final public static  intVK_LEFT
     Constant for the non-numpad left arrow key.
final public static  intVK_LEFT_PARENTHESIS
     Constant for the "(" key.
final public static  intVK_LESS
    
final public static  intVK_M
    
final public static  intVK_META
    
final public static  intVK_MINUS
    
final public static  intVK_MODECHANGE
    
final public static  intVK_MULTIPLY
    
final public static  intVK_N
    
final public static  intVK_NONCONVERT
     Constant for the Don't Convert function key.
final public static  intVK_NUMBER_SIGN
     Constant for the "#" key.
final public static  intVK_NUMPAD0
    
final public static  intVK_NUMPAD1
    
final public static  intVK_NUMPAD2
    
final public static  intVK_NUMPAD3
    
final public static  intVK_NUMPAD4
    
final public static  intVK_NUMPAD5
    
final public static  intVK_NUMPAD6
    
final public static  intVK_NUMPAD7
    
final public static  intVK_NUMPAD8
    
final public static  intVK_NUMPAD9
    
final public static  intVK_NUM_LOCK
    
final public static  intVK_O
    
final public static  intVK_OPEN_BRACKET
    
final public static  intVK_P
    
final public static  intVK_PAGE_DOWN
    
final public static  intVK_PAGE_UP
    
final public static  intVK_PASTE
    
final public static  intVK_PAUSE
    
final public static  intVK_PERIOD
    
final public static  intVK_PLUS
     Constant for the "+" key.
final public static  intVK_PREVIOUS_CANDIDATE
     Constant for the Previous Candidate function key.
final public static  intVK_PRINTSCREEN
    
final public static  intVK_PROPS
    
final public static  intVK_Q
    
final public static  intVK_QUOTE
    
final public static  intVK_QUOTEDBL
    
final public static  intVK_R
    
final public static  intVK_RIGHT
     Constant for the non-numpad right arrow key.
final public static  intVK_RIGHT_PARENTHESIS
     Constant for the ")" key.
final public static  intVK_ROMAN_CHARACTERS
     Constant for the Roman Characters function key.
final public static  intVK_S
    
final public static  intVK_SCROLL_LOCK
    
final public static  intVK_SEMICOLON
    
final public static  intVK_SEPARATER
     This constant is obsolete, and is included only for backwards compatibility.
final public static  intVK_SEPARATOR
     Constant for the Numpad Separator key.
final public static  intVK_SHIFT
    
final public static  intVK_SLASH
    
final public static  intVK_SPACE
    
final public static  intVK_STOP
    
final public static  intVK_SUBTRACT
    
final public static  intVK_T
    
final public static  intVK_TAB
    
final public static  intVK_U
    
final public static  intVK_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.
final public static  intVK_UNDERSCORE
     Constant for the "_" key.
final public static  intVK_UNDO
    
final public static  intVK_UP
     Constant for the non-numpad up arrow key.
final public static  intVK_V
    
final public static  intVK_W
    
final public static  intVK_WINDOWS
     Constant for the Microsoft Windows "Windows" key. It is used for both the left and right version of the key.
final public static  intVK_X
    
final public static  intVK_Y
    
final public static  intVK_Z
    
 charkeyChar
     keyChar is a valid unicode character that is fired by a key or a key combination on a keyboard.
 intkeyCode
     The unique value assigned to each of the keys on the keyboard.
 intkeyLocation
     The location of the key on the keyboard. Some keys occur more than once on a keyboard, e.g.

Constructor Summary
public  KeyEvent(Component source, int id, long when, int modifiers, int keyCode, char keyChar, int keyLocation)
     Constructs a KeyEvent object.

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

public  KeyEvent(Component source, int id, long when, int modifiers, int keyCode, char keyChar)
     Constructs a KeyEvent object.

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

public  KeyEvent(Component source, int id, long when, int modifiers, int keyCode)
    

Method Summary
public  chargetKeyChar()
     Returns the character associated with the key in this event. For example, the KEY_TYPED event for shift + "a" returns the value for "A".

KEY_PRESSED and KEY_RELEASED events are not intended for reporting of character input.

public  intgetKeyCode()
     Returns the integer keyCode associated with the key in this event. the integer code for an actual key on the keyboard.
public  intgetKeyLocation()
     Returns the location of the key that originated this key event. Some keys occur more than once on a keyboard, e.g.
public static  StringgetKeyModifiersText(int modifiers)
     Returns a String describing the modifier key(s), such as "Shift", or "Ctrl+Shift".
public static  StringgetKeyText(int keyCode)
     Returns a String describing the keyCode, such as "HOME", "F1" or "A".
public  booleanisActionKey()
     Returns whether the key in this event is an "action" key.
public  StringparamString()
     Returns a parameter string identifying this event.
public  voidsetKeyChar(char keyChar)
     Set the keyChar value to indicate a logical character.
public  voidsetKeyCode(int keyCode)
     Set the keyCode value to indicate a physical key.
public  voidsetModifiers(int modifiers)
     Set the modifiers to indicate additional keys that were held down (e.g.

Field Detail
CHAR_UNDEFINED
final public static char CHAR_UNDEFINED(Code)
KEY_PRESSED and KEY_RELEASED events which do not map to a valid Unicode character use this for the keyChar value.



KEY_FIRST
final public static int KEY_FIRST(Code)
The first number in the range of ids used for key events.



KEY_LAST
final public static int KEY_LAST(Code)
The last number in the range of ids used for key events.



KEY_LOCATION_LEFT
final public static int KEY_LOCATION_LEFT(Code)
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_NUMPAD
final public static int KEY_LOCATION_NUMPAD(Code)
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_RIGHT
final public static int KEY_LOCATION_RIGHT(Code)
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_STANDARD
final public static int KEY_LOCATION_STANDARD(Code)
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_UNKNOWN
final public static int KEY_LOCATION_UNKNOWN(Code)
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_PRESSED
final public static int KEY_PRESSED(Code)
The "key pressed" event. This event is generated when a key is pushed down.



KEY_RELEASED
final public static int KEY_RELEASED(Code)
The "key released" event. This event is generated when a key is let up.



KEY_TYPED
final public static int KEY_TYPED(Code)
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.



VK_0
final public static int VK_0(Code)
VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39)



VK_1
final public static int VK_1(Code)



VK_2
final public static int VK_2(Code)



VK_3
final public static int VK_3(Code)



VK_4
final public static int VK_4(Code)



VK_5
final public static int VK_5(Code)



VK_6
final public static int VK_6(Code)



VK_7
final public static int VK_7(Code)



VK_8
final public static int VK_8(Code)



VK_9
final public static int VK_9(Code)



VK_A
final public static int VK_A(Code)
VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A)



VK_ACCEPT
final public static int VK_ACCEPT(Code)
Constant for the Accept or Commit function key.



VK_ADD
final public static int VK_ADD(Code)



VK_AGAIN
final public static int VK_AGAIN(Code)

since:
   1.2



VK_ALL_CANDIDATES
final public static int VK_ALL_CANDIDATES(Code)
Constant for the All Candidates function key.
since:
   1.2



VK_ALPHANUMERIC
final public static int VK_ALPHANUMERIC(Code)
Constant for the Alphanumeric function key.
since:
   1.2



VK_ALT
final public static int VK_ALT(Code)



VK_ALT_GRAPH
final public static int VK_ALT_GRAPH(Code)
Constant for the AltGraph function key.
since:
   1.2



VK_AMPERSAND
final public static int VK_AMPERSAND(Code)

since:
   1.2



VK_ASTERISK
final public static int VK_ASTERISK(Code)

since:
   1.2



VK_AT
final public static int VK_AT(Code)
Constant for the "@" key.
since:
   1.2



VK_B
final public static int VK_B(Code)



VK_BACK_QUOTE
final public static int VK_BACK_QUOTE(Code)



VK_BACK_SLASH
final public static int VK_BACK_SLASH(Code)
Constant for the back slash key, "\"



VK_BACK_SPACE
final public static int VK_BACK_SPACE(Code)



VK_BEGIN
final public static int VK_BEGIN(Code)
Constant for the Begin key.
since:
   1.5



VK_BRACELEFT
final public static int VK_BRACELEFT(Code)

since:
   1.2



VK_BRACERIGHT
final public static int VK_BRACERIGHT(Code)

since:
   1.2



VK_C
final public static int VK_C(Code)



VK_CANCEL
final public static int VK_CANCEL(Code)



VK_CAPS_LOCK
final public static int VK_CAPS_LOCK(Code)



VK_CIRCUMFLEX
final public static int VK_CIRCUMFLEX(Code)
Constant for the "^" key.
since:
   1.2



VK_CLEAR
final public static int VK_CLEAR(Code)



VK_CLOSE_BRACKET
final public static int VK_CLOSE_BRACKET(Code)
Constant for the close bracket key, "]"



VK_CODE_INPUT
final public static int VK_CODE_INPUT(Code)
Constant for the Code Input function key.
since:
   1.2



VK_COLON
final public static int VK_COLON(Code)
Constant for the ":" key.
since:
   1.2



VK_COMMA
final public static int VK_COMMA(Code)
Constant for the comma key, ","



VK_COMPOSE
final public static int VK_COMPOSE(Code)
Constant for the Compose function key.
since:
   1.2



VK_CONTEXT_MENU
final public static int VK_CONTEXT_MENU(Code)
Constant for the Microsoft Windows Context Menu key.
since:
   1.5



VK_CONTROL
final public static int VK_CONTROL(Code)



VK_CONVERT
final public static int VK_CONVERT(Code)
Constant for the Convert function key.



VK_COPY
final public static int VK_COPY(Code)

since:
   1.2



VK_CUT
final public static int VK_CUT(Code)

since:
   1.2



VK_D
final public static int VK_D(Code)



VK_DEAD_ABOVEDOT
final public static int VK_DEAD_ABOVEDOT(Code)

since:
   1.2



VK_DEAD_ABOVERING
final public static int VK_DEAD_ABOVERING(Code)

since:
   1.2



VK_DEAD_ACUTE
final public static int VK_DEAD_ACUTE(Code)

since:
   1.2



VK_DEAD_BREVE
final public static int VK_DEAD_BREVE(Code)

since:
   1.2



VK_DEAD_CARON
final public static int VK_DEAD_CARON(Code)

since:
   1.2



VK_DEAD_CEDILLA
final public static int VK_DEAD_CEDILLA(Code)

since:
   1.2



VK_DEAD_CIRCUMFLEX
final public static int VK_DEAD_CIRCUMFLEX(Code)

since:
   1.2



VK_DEAD_DIAERESIS
final public static int VK_DEAD_DIAERESIS(Code)

since:
   1.2



VK_DEAD_DOUBLEACUTE
final public static int VK_DEAD_DOUBLEACUTE(Code)

since:
   1.2



VK_DEAD_GRAVE
final public static int VK_DEAD_GRAVE(Code)

since:
   1.2



VK_DEAD_IOTA
final public static int VK_DEAD_IOTA(Code)

since:
   1.2



VK_DEAD_MACRON
final public static int VK_DEAD_MACRON(Code)

since:
   1.2



VK_DEAD_OGONEK
final public static int VK_DEAD_OGONEK(Code)

since:
   1.2



VK_DEAD_SEMIVOICED_SOUND
final public static int VK_DEAD_SEMIVOICED_SOUND(Code)

since:
   1.2



VK_DEAD_TILDE
final public static int VK_DEAD_TILDE(Code)

since:
   1.2



VK_DEAD_VOICED_SOUND
final public static int VK_DEAD_VOICED_SOUND(Code)

since:
   1.2



VK_DECIMAL
final public static int VK_DECIMAL(Code)



VK_DELETE
final public static int VK_DELETE(Code)



VK_DIVIDE
final public static int VK_DIVIDE(Code)



VK_DOLLAR
final public static int VK_DOLLAR(Code)
Constant for the "$" key.
since:
   1.2



VK_DOWN
final public static int VK_DOWN(Code)
Constant for the non-numpad down arrow key.
See Also:   KeyEvent.VK_KP_DOWN



VK_E
final public static int VK_E(Code)



VK_END
final public static int VK_END(Code)



VK_ENTER
final public static int VK_ENTER(Code)



VK_EQUALS
final public static int VK_EQUALS(Code)
Constant for the equals key, "="



VK_ESCAPE
final public static int VK_ESCAPE(Code)



VK_EURO_SIGN
final public static int VK_EURO_SIGN(Code)
Constant for the Euro currency sign key.
since:
   1.2



VK_EXCLAMATION_MARK
final public static int VK_EXCLAMATION_MARK(Code)
Constant for the "!" key.
since:
   1.2



VK_F
final public static int VK_F(Code)



VK_F1
final public static int VK_F1(Code)
Constant for the F1 function key.



VK_F10
final public static int VK_F10(Code)
Constant for the F10 function key.



VK_F11
final public static int VK_F11(Code)
Constant for the F11 function key.



VK_F12
final public static int VK_F12(Code)
Constant for the F12 function key.



VK_F13
final public static int VK_F13(Code)
Constant for the F13 function key.
since:
   1.2



VK_F14
final public static int VK_F14(Code)
Constant for the F14 function key.
since:
   1.2



VK_F15
final public static int VK_F15(Code)
Constant for the F15 function key.
since:
   1.2



VK_F16
final public static int VK_F16(Code)
Constant for the F16 function key.
since:
   1.2



VK_F17
final public static int VK_F17(Code)
Constant for the F17 function key.
since:
   1.2



VK_F18
final public static int VK_F18(Code)
Constant for the F18 function key.
since:
   1.2



VK_F19
final public static int VK_F19(Code)
Constant for the F19 function key.
since:
   1.2



VK_F2
final public static int VK_F2(Code)
Constant for the F2 function key.



VK_F20
final public static int VK_F20(Code)
Constant for the F20 function key.
since:
   1.2



VK_F21
final public static int VK_F21(Code)
Constant for the F21 function key.
since:
   1.2



VK_F22
final public static int VK_F22(Code)
Constant for the F22 function key.
since:
   1.2



VK_F23
final public static int VK_F23(Code)
Constant for the F23 function key.
since:
   1.2



VK_F24
final public static int VK_F24(Code)
Constant for the F24 function key.
since:
   1.2



VK_F3
final public static int VK_F3(Code)
Constant for the F3 function key.



VK_F4
final public static int VK_F4(Code)
Constant for the F4 function key.



VK_F5
final public static int VK_F5(Code)
Constant for the F5 function key.



VK_F6
final public static int VK_F6(Code)
Constant for the F6 function key.



VK_F7
final public static int VK_F7(Code)
Constant for the F7 function key.



VK_F8
final public static int VK_F8(Code)
Constant for the F8 function key.



VK_F9
final public static int VK_F9(Code)
Constant for the F9 function key.



VK_FINAL
final public static int VK_FINAL(Code)



VK_FIND
final public static int VK_FIND(Code)

since:
   1.2



VK_FULL_WIDTH
final public static int VK_FULL_WIDTH(Code)
Constant for the Full-Width Characters function key.
since:
   1.2



VK_G
final public static int VK_G(Code)



VK_GREATER
final public static int VK_GREATER(Code)

since:
   1.2



VK_H
final public static int VK_H(Code)



VK_HALF_WIDTH
final public static int VK_HALF_WIDTH(Code)
Constant for the Half-Width Characters function key.
since:
   1.2



VK_HELP
final public static int VK_HELP(Code)



VK_HIRAGANA
final public static int VK_HIRAGANA(Code)
Constant for the Hiragana function key.
since:
   1.2



VK_HOME
final public static int VK_HOME(Code)



VK_I
final public static int VK_I(Code)



VK_INPUT_METHOD_ON_OFF
final public static int VK_INPUT_METHOD_ON_OFF(Code)
Constant for the input method on/off key.
since:
   1.3



VK_INSERT
final public static int VK_INSERT(Code)



VK_INVERTED_EXCLAMATION_MARK
final public static int VK_INVERTED_EXCLAMATION_MARK(Code)
Constant for the inverted exclamation mark key.
since:
   1.2



VK_J
final public static int VK_J(Code)



VK_JAPANESE_HIRAGANA
final public static int VK_JAPANESE_HIRAGANA(Code)
Constant for the Japanese-Hiragana function key. This key switches to a Japanese input method and selects its Hiragana input mode.
since:
   1.2



VK_JAPANESE_KATAKANA
final public static int VK_JAPANESE_KATAKANA(Code)
Constant for the Japanese-Katakana function key. This key switches to a Japanese input method and selects its Katakana input mode.
since:
   1.2



VK_JAPANESE_ROMAN
final public static int VK_JAPANESE_ROMAN(Code)
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



VK_K
final public static int VK_K(Code)



VK_KANA
final public static int VK_KANA(Code)



VK_KANA_LOCK
final public static int VK_KANA_LOCK(Code)
Constant for the locking Kana function key. This key locks the keyboard into a Kana layout.
since:
   1.3



VK_KANJI
final public static int VK_KANJI(Code)



VK_KATAKANA
final public static int VK_KATAKANA(Code)
Constant for the Katakana function key.
since:
   1.2



VK_KP_DOWN
final public static int VK_KP_DOWN(Code)
Constant for the numeric keypad down arrow key.
See Also:   KeyEvent.VK_DOWN
since:
   1.2



VK_KP_LEFT
final public static int VK_KP_LEFT(Code)
Constant for the numeric keypad left arrow key.
See Also:   KeyEvent.VK_LEFT
since:
   1.2



VK_KP_RIGHT
final public static int VK_KP_RIGHT(Code)
Constant for the numeric keypad right arrow key.
See Also:   KeyEvent.VK_RIGHT
since:
   1.2



VK_KP_UP
final public static int VK_KP_UP(Code)
Constant for the numeric keypad up arrow key.
See Also:   KeyEvent.VK_UP
since:
   1.2



VK_L
final public static int VK_L(Code)



VK_LEFT
final public static int VK_LEFT(Code)
Constant for the non-numpad left arrow key.
See Also:   KeyEvent.VK_KP_LEFT



VK_LEFT_PARENTHESIS
final public static int VK_LEFT_PARENTHESIS(Code)
Constant for the "(" key.
since:
   1.2



VK_LESS
final public static int VK_LESS(Code)

since:
   1.2



VK_M
final public static int VK_M(Code)



VK_META
final public static int VK_META(Code)



VK_MINUS
final public static int VK_MINUS(Code)
Constant for the minus key, "-"
since:
   1.2



VK_MODECHANGE
final public static int VK_MODECHANGE(Code)



VK_MULTIPLY
final public static int VK_MULTIPLY(Code)



VK_N
final public static int VK_N(Code)



VK_NONCONVERT
final public static int VK_NONCONVERT(Code)
Constant for the Don't Convert function key.



VK_NUMBER_SIGN
final public static int VK_NUMBER_SIGN(Code)
Constant for the "#" key.
since:
   1.2



VK_NUMPAD0
final public static int VK_NUMPAD0(Code)



VK_NUMPAD1
final public static int VK_NUMPAD1(Code)



VK_NUMPAD2
final public static int VK_NUMPAD2(Code)



VK_NUMPAD3
final public static int VK_NUMPAD3(Code)



VK_NUMPAD4
final public static int VK_NUMPAD4(Code)



VK_NUMPAD5
final public static int VK_NUMPAD5(Code)



VK_NUMPAD6
final public static int VK_NUMPAD6(Code)



VK_NUMPAD7
final public static int VK_NUMPAD7(Code)



VK_NUMPAD8
final public static int VK_NUMPAD8(Code)



VK_NUMPAD9
final public static int VK_NUMPAD9(Code)



VK_NUM_LOCK
final public static int VK_NUM_LOCK(Code)



VK_O
final public static int VK_O(Code)



VK_OPEN_BRACKET
final public static int VK_OPEN_BRACKET(Code)
Constant for the open bracket key, "["



VK_P
final public static int VK_P(Code)



VK_PAGE_DOWN
final public static int VK_PAGE_DOWN(Code)



VK_PAGE_UP
final public static int VK_PAGE_UP(Code)



VK_PASTE
final public static int VK_PASTE(Code)

since:
   1.2



VK_PAUSE
final public static int VK_PAUSE(Code)



VK_PERIOD
final public static int VK_PERIOD(Code)
Constant for the period key, "."



VK_PLUS
final public static int VK_PLUS(Code)
Constant for the "+" key.
since:
   1.2



VK_PREVIOUS_CANDIDATE
final public static int VK_PREVIOUS_CANDIDATE(Code)
Constant for the Previous Candidate function key.
since:
   1.2



VK_PRINTSCREEN
final public static int VK_PRINTSCREEN(Code)



VK_PROPS
final public static int VK_PROPS(Code)

since:
   1.2



VK_Q
final public static int VK_Q(Code)



VK_QUOTE
final public static int VK_QUOTE(Code)



VK_QUOTEDBL
final public static int VK_QUOTEDBL(Code)

since:
   1.2



VK_R
final public static int VK_R(Code)



VK_RIGHT
final public static int VK_RIGHT(Code)
Constant for the non-numpad right arrow key.
See Also:   KeyEvent.VK_KP_RIGHT



VK_RIGHT_PARENTHESIS
final public static int VK_RIGHT_PARENTHESIS(Code)
Constant for the ")" key.
since:
   1.2



VK_ROMAN_CHARACTERS
final public static int VK_ROMAN_CHARACTERS(Code)
Constant for the Roman Characters function key.
since:
   1.2



VK_S
final public static int VK_S(Code)



VK_SCROLL_LOCK
final public static int VK_SCROLL_LOCK(Code)



VK_SEMICOLON
final public static int VK_SEMICOLON(Code)
Constant for the semicolon key, ";"



VK_SEPARATER
final public static int VK_SEPARATER(Code)
This constant is obsolete, and is included only for backwards compatibility.
See Also:   KeyEvent.VK_SEPARATOR



VK_SEPARATOR
final public static int VK_SEPARATOR(Code)
Constant for the Numpad Separator key.
since:
   1.4



VK_SHIFT
final public static int VK_SHIFT(Code)



VK_SLASH
final public static int VK_SLASH(Code)
Constant for the forward slash key, "/"



VK_SPACE
final public static int VK_SPACE(Code)



VK_STOP
final public static int VK_STOP(Code)

since:
   1.2



VK_SUBTRACT
final public static int VK_SUBTRACT(Code)



VK_T
final public static int VK_T(Code)



VK_TAB
final public static int VK_TAB(Code)



VK_U
final public static int VK_U(Code)



VK_UNDEFINED
final public static int VK_UNDEFINED(Code)
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.



VK_UNDERSCORE
final public static int VK_UNDERSCORE(Code)
Constant for the "_" key.
since:
   1.2



VK_UNDO
final public static int VK_UNDO(Code)

since:
   1.2



VK_UP
final public static int VK_UP(Code)
Constant for the non-numpad up arrow key.
See Also:   KeyEvent.VK_KP_UP



VK_V
final public static int VK_V(Code)



VK_W
final public static int VK_W(Code)



VK_WINDOWS
final public static int VK_WINDOWS(Code)
Constant for the Microsoft Windows "Windows" key. It is used for both the left and right version of the key.
See Also:   KeyEvent.getKeyLocation()
since:
   1.5



VK_X
final public static int VK_X(Code)



VK_Y
final public static int VK_Y(Code)



VK_Z
final public static int VK_Z(Code)



keyChar
char keyChar(Code)
keyChar is a valid unicode character that is fired by a key or a key combination on a keyboard.
See Also:   KeyEvent.getKeyChar()
See Also:   KeyEvent.setKeyChar(char)



keyCode
int keyCode(Code)
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:   KeyEvent.getKeyCode()
See Also:   KeyEvent.setKeyCode(int)



keyLocation
int keyLocation(Code)
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:   KeyEvent.getKeyLocation()




Constructor Detail
KeyEvent
public KeyEvent(Component source, int id, long when, int modifiers, int keyCode, char keyChar, int keyLocation)(Code)
Constructs a KeyEvent object.

Note that passing in an invalid id results in unspecified behavior. This method throws an IllegalArgumentException if source is null.
Parameters:
  source - the Component that originated the event
Parameters:
  id - an integer identifying the type of event
Parameters:
  when - a long integer that specifies the time the eventoccurred
Parameters:
  modifiers - the modifier keys down during event (shift, ctrl,alt, meta)Either extended _DOWN_MASK or old _MASK modifiersshould be used, but both models should not be mixedin one event. Use of the extended modifiers ispreferred.
Parameters:
  keyCode - the integer code for an actual key, or VK_UNDEFINED(for a key-typed event)
Parameters:
  keyChar - the Unicode character generated by this event, orCHAR_UNDEFINED (for key-pressed and key-releasedevents which do not map to a valid Unicode character)
Parameters:
  keyLocation - identifies the key location. The only legalvalues are KEY_LOCATION_UNKNOWN, KEY_LOCATION_STANDARD, KEY_LOCATION_LEFT, KEY_LOCATION_RIGHT, and KEY_LOCATION_NUMPAD.
throws:
  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 andkeyLocation is not KEY_LOCATION_UNKNOWN;or if keyLocation is not one of the legal values enumerated above.
throws:
  IllegalArgumentException - if source is null
since:
   1.4




KeyEvent
public KeyEvent(Component source, int id, long when, int modifiers, int keyCode, char keyChar)(Code)
Constructs a KeyEvent object.

Note that passing in an invalid id results in unspecified behavior. This method throws an IllegalArgumentException if source is null.
Parameters:
  source - the Component that originated the event
Parameters:
  id - an integer identifying the type of event
Parameters:
  when - a long integer that specifies the time the eventoccurred
Parameters:
  modifiers - the modifier keys down during event (shift, ctrl,alt, meta)Either extended _DOWN_MASK or old _MASK modifiersshould be used, but both models should not be mixedin one event. Use of the extended modifiers ispreferred.
Parameters:
  keyCode - the integer code for an actual key, or VK_UNDEFINED (for a key-typed event)
Parameters:
  keyChar - the Unicode character generated by this event, or CHAR_UNDEFINED (for key-pressed and key-releasedevents which do not map to a valid Unicode character)
throws:
  IllegalArgumentException - if id isKEY_TYPED and keyChar isCHAR_UNDEFINED; or if id isKEY_TYPED and keyCode is notVK_UNDEFINED
throws:
  IllegalArgumentException - if source is null




KeyEvent
public KeyEvent(Component source, int id, long when, int modifiers, int keyCode)(Code)




Method Detail
getKeyChar
public char getKeyChar()(Code)
Returns the character associated with the key in this event. For example, the KEY_TYPED event for shift + "a" returns the value for "A".

KEY_PRESSED and KEY_RELEASED events are not intended for reporting of character input. Therefore, the values returned by this method are guaranteed to be meaningful only for KEY_TYPED events. the Unicode character defined for this key event.If no valid Unicode character exists for this key event, CHAR_UNDEFINED is returned.




getKeyCode
public int getKeyCode()(Code)
Returns the integer keyCode associated with the key in this event. the integer code for an actual key on the keyboard. (For KEY_TYPED events, the keyCode is VK_UNDEFINED.)



getKeyLocation
public int getKeyLocation()(Code)
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. the location of the key that was pressed or released.Always returns KEY_LOCATION_UNKNOWN for KEY_TYPED events.
since:
   1.4



getKeyModifiersText
public static String getKeyModifiersText(int modifiers)(Code)
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.

Note that InputEvent.ALT_MASK and InputEvent.BUTTON2_MASK have the same value, so the string "Alt" is returned for both modifiers. Likewise, InputEvent.META_MASK and InputEvent.BUTTON3_MASK have the same value, so the string "Meta" is returned for both modifiers. string a text description of the combination of modifierkeys that were held down during the event
See Also:   InputEvent.getModifiersExText(int)




getKeyText
public static String getKeyText(int keyCode)(Code)
Returns a String describing the keyCode, such as "HOME", "F1" or "A". These strings can be localized by changing the awt.properties file. a string containing a text description for a physical key,identified by its keyCode



isActionKey
public boolean isActionKey()(Code)
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. true if the key is an "action" key,false otherwise



paramString
public String paramString()(Code)
Returns a parameter string identifying this event. This method is useful for event logging and for debugging. a string identifying the event and its attributes



setKeyChar
public void setKeyChar(char keyChar)(Code)
Set the keyChar value to indicate a logical character.
Parameters:
  keyChar - a char corresponding to to the combination of keystrokesthat make up this event.



setKeyCode
public void setKeyCode(int keyCode)(Code)
Set the keyCode value to indicate a physical key.
Parameters:
  keyCode - an integer corresponding to an actual key on the keyboard.



setModifiers
public void setModifiers(int modifiers)(Code)
Set the modifiers to indicate additional keys that were held down (e.g. shift, ctrl, alt, meta) defined as part of InputEvent.

NOTE: use of this method is not recommended, because many AWT implementations do not recognize modifier changes. This is especially true for KEY_TYPED events where the shift modifier is changed.
Parameters:
  modifiers - an integer combination of the modifier constants.
See Also:   InputEvent




Fields inherited from java.awt.event.InputEvent
final public static int ALT_DOWN_MASK(Code)(Java Doc)
final public static int ALT_GRAPH_DOWN_MASK(Code)(Java Doc)
final public static int ALT_GRAPH_MASK(Code)(Java Doc)
final public static int ALT_MASK(Code)(Java Doc)
final public static int BUTTON1_DOWN_MASK(Code)(Java Doc)
final public static int BUTTON1_MASK(Code)(Java Doc)
final public static int BUTTON2_DOWN_MASK(Code)(Java Doc)
final public static int BUTTON2_MASK(Code)(Java Doc)
final public static int BUTTON3_DOWN_MASK(Code)(Java Doc)
final public static int BUTTON3_MASK(Code)(Java Doc)
final public static int CTRL_DOWN_MASK(Code)(Java Doc)
final public static int CTRL_MASK(Code)(Java Doc)
final static int FIRST_HIGH_BIT(Code)(Java Doc)
final static int HIGH_MODIFIERS(Code)(Java Doc)
final static int JDK_1_3_MODIFIERS(Code)(Java Doc)
final public static int META_DOWN_MASK(Code)(Java Doc)
final public static int META_MASK(Code)(Java Doc)
final public static int SHIFT_DOWN_MASK(Code)(Java Doc)
final public static int SHIFT_MASK(Code)(Java Doc)
int modifiers(Code)(Java Doc)
final static long serialVersionUID(Code)(Java Doc)
long when(Code)(Java Doc)

Methods inherited from java.awt.event.InputEvent
public void consume()(Code)(Java Doc)
public int getModifiers()(Code)(Java Doc)
public int getModifiersEx()(Code)(Java Doc)
public static String getModifiersExText(int modifiers)(Code)(Java Doc)
public long getWhen()(Code)(Java Doc)
public boolean isAltDown()(Code)(Java Doc)
public boolean isAltGraphDown()(Code)(Java Doc)
public boolean isConsumed()(Code)(Java Doc)
public boolean isControlDown()(Code)(Java Doc)
public boolean isMetaDown()(Code)(Java Doc)
public boolean isShiftDown()(Code)(Java Doc)

Fields inherited from java.awt.event.ComponentEvent
final public static int COMPONENT_FIRST(Code)(Java Doc)
final public static int COMPONENT_HIDDEN(Code)(Java Doc)
final public static int COMPONENT_LAST(Code)(Java Doc)
final public static int COMPONENT_MOVED(Code)(Java Doc)
final public static int COMPONENT_RESIZED(Code)(Java Doc)
final public static int COMPONENT_SHOWN(Code)(Java Doc)

Methods inherited from java.awt.event.ComponentEvent
public Component getComponent()(Code)(Java Doc)
public String paramString()(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.