Class NativeKeyEvent
- java.lang.Object
-
- java.util.EventObject
-
- com.github.kwhat.jnativehook.NativeInputEvent
-
- com.github.kwhat.jnativehook.keyboard.NativeKeyEvent
-
- All Implemented Interfaces:
Serializable
public class NativeKeyEvent extends NativeInputEvent
An event which indicates that a keystroke occurred at global scope.This low-level event is generated by the native system when a key is pressed or released independent of Java component focus. The event is passed to every
NativeKeyListenerobject which has been registered to receive global key events using theGlobalScreen.addNativeKeyListener(NativeKeyListener)method. EachNativeKeyListenerobject will receive aNativeKeyEventwhen the event occurs.All
NativeKeyEventobjects are dependent on the native platform and keyboard layout.NATIVE_KEY_PRESSEDandNATIVE_KEY_RELEASEDevents are generated for every key code received by the native system. The key being pressed or released is indicated by the getKeyCode method, which returns a virtual key code orVC_UNDEFINED. Please note thatgetKeyChar()for events of typeNATIVE_KEY_PRESSEDandNATIVE_KEY_RELEASEDwill always returnCHAR_UNDEFINED.NATIVE_KEY_TYPEDevents are produced forNATIVE_KEY_PRESSEDevents that produce valid Unicode characters for the current keyboard layout. ThegetKeyChar()method always returns a valid Unicode character for this type of event. Please note thatgetKeyCode()will always returnVC_UNDEFINEDforNATIVE_KEY_TYPEDevents.Virtual key codes only represent the physical key that has been pressed and should not be mistaken with the character mapped to that key by the operating system.
NATIVE_KEY_PRESSEDandNATIVE_KEY_RELEASEDevents should only be used to determin phisical key state, whileNATIVE_KEY_TYPEDevents can be used to determine the Unicode representation of theNativeKeyEvent.- Since:
- 1.0
- Version:
- 2.0
- Author:
- Alexander Barker (alex@1stleg.com)
- See Also:
GlobalScreen,NativeKeyListener, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static charCHAR_UNDEFINEDThis is used to indicate that the keyChar is undefined.static intKEY_LOCATION_LEFTstatic intKEY_LOCATION_NUMPADstatic intKEY_LOCATION_RIGHTstatic intKEY_LOCATION_STANDARDstatic intKEY_LOCATION_UNKNOWNstatic intNATIVE_KEY_FIRSTThe first number in the range of ID's used for native key events.static intNATIVE_KEY_LASTThe last number in the range of ID's used for native key events.static intNATIVE_KEY_PRESSEDThe "native key pressed" event ID.static intNATIVE_KEY_RELEASEDThe "native key released" event ID.static intNATIVE_KEY_TYPEDThe "native key typed" event ID.static intVC_0static intVC_1VC_0 thru VC_9static intVC_2static intVC_3static intVC_4static intVC_5static intVC_6static intVC_7static intVC_8static intVC_9static intVC_AVC_A thru VC_Zstatic intVC_ALTstatic intVC_APP_CALCULATORstatic intVC_APP_MAILstatic intVC_APP_MUSICstatic intVC_APP_PICTURESstatic intVC_Bstatic intVC_BACK_SLASHstatic intVC_BACKQUOTEstatic intVC_BACKSPACEstatic intVC_BROWSER_BACKstatic intVC_BROWSER_FAVORITESstatic intVC_BROWSER_FORWARDstatic intVC_BROWSER_HOMEstatic intVC_BROWSER_REFRESHstatic intVC_BROWSER_SEARCHstatic intVC_BROWSER_STOPstatic intVC_Cstatic intVC_CAPS_LOCKstatic intVC_CLEARstatic intVC_CLOSE_BRACKETstatic intVC_COMMAstatic intVC_CONTEXT_MENUstatic intVC_CONTROLstatic intVC_Dstatic intVC_DELETEstatic intVC_DOWNstatic intVC_Estatic intVC_ENDstatic intVC_ENTERstatic intVC_EQUALSstatic intVC_ESCAPEstatic intVC_Fstatic intVC_F1Constants for the F1 through F24 function keys.static intVC_F10static intVC_F11static intVC_F12static intVC_F13static intVC_F14static intVC_F15static intVC_F16static intVC_F17static intVC_F18static intVC_F19static intVC_F2static intVC_F20static intVC_F21static intVC_F22static intVC_F23static intVC_F24static intVC_F3static intVC_F4static intVC_F5static intVC_F6static intVC_F7static intVC_F8static intVC_F9static intVC_FURIGANAstatic intVC_Gstatic intVC_Hstatic intVC_HIRAGANAstatic intVC_HOMEstatic intVC_Istatic intVC_INSERTEdit Key Zonestatic intVC_Jstatic intVC_Kstatic intVC_KANJIstatic intVC_KATAKANAJapanese Language Keysstatic intVC_Lstatic intVC_LEFTstatic intVC_Mstatic intVC_MEDIA_EJECTstatic intVC_MEDIA_NEXTstatic intVC_MEDIA_PLAYstatic intVC_MEDIA_PREVIOUSstatic intVC_MEDIA_SELECTstatic intVC_MEDIA_STOPstatic intVC_METAstatic intVC_MINUSstatic intVC_Nstatic intVC_NUM_LOCKBegin Numeric Zonestatic intVC_Ostatic intVC_OPEN_BRACKETstatic intVC_Pstatic intVC_PAGE_DOWNstatic intVC_PAGE_UPstatic intVC_PAUSEstatic intVC_PERIODstatic intVC_POWERMedia and Extra Keysstatic intVC_PRINTSCREENstatic intVC_Qstatic intVC_QUOTEstatic intVC_Rstatic intVC_RIGHTstatic intVC_Sstatic intVC_SCROLL_LOCKstatic intVC_SEMICOLONstatic intVC_SEPARATORstatic intVC_SHIFTModifier and Control Keysstatic intVC_SLASHstatic intVC_SLEEPstatic intVC_SPACEstatic intVC_SUN_AGAINstatic intVC_SUN_COPYstatic intVC_SUN_CUTstatic intVC_SUN_FINDstatic intVC_SUN_FRONTstatic intVC_SUN_HELPSun keyboardsstatic intVC_SUN_INSERTstatic intVC_SUN_OPENstatic intVC_SUN_PROPSstatic intVC_SUN_STOPstatic intVC_SUN_UNDOstatic intVC_Tstatic intVC_TABstatic intVC_Ustatic intVC_UNDEFINEDThis value is used to indicate that the keyCode is unknown.static intVC_UNDERSCOREstatic intVC_UPBegin Cursor Key Zonestatic intVC_Vstatic intVC_VOLUME_DOWNstatic intVC_VOLUME_MUTEstatic intVC_VOLUME_UPstatic intVC_Wstatic intVC_WAKEstatic intVC_Xstatic intVC_Ystatic intVC_YENstatic intVC_Z-
Fields inherited from class com.github.kwhat.jnativehook.NativeInputEvent
ALT_L_MASK, ALT_MASK, ALT_R_MASK, BUTTON1_MASK, BUTTON2_MASK, BUTTON3_MASK, BUTTON4_MASK, BUTTON5_MASK, CAPS_LOCK_MASK, CTRL_L_MASK, CTRL_MASK, CTRL_R_MASK, META_L_MASK, META_MASK, META_R_MASK, NUM_LOCK_MASK, SCROLL_LOCK_MASK, SHIFT_L_MASK, SHIFT_MASK, SHIFT_R_MASK
-
Fields inherited from class java.util.EventObject
source
-
-
Constructor Summary
Constructors Constructor Description NativeKeyEvent(int id, int modifiers, int rawCode, int keyCode, char keyChar)Instantiates a new native key event.NativeKeyEvent(int id, int modifiers, int rawCode, int keyCode, char keyChar, int keyLocation)Instantiates a new native key event.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description chargetKeyChar()Returns the native Unicode character associated with this event.intgetKeyCode()Returns the keyCode associated with this event.intgetKeyLocation()Returns the location of the virtual key for this event.static StringgetKeyText(int keyCode)Returns a String describing the keyCode, such as "HOME", "F1" or "A".intgetRawCode()Returns the native code associated with the native key in this event.booleanisActionKey()Returns whether the key in this event is an "action" key.StringparamString()Returns a parameter string identifying this event.voidsetKeyChar(char keyChar)Set the keyChar value in this event.voidsetKeyCode(int keyCode)Set the keyCode value in this event.voidsetRawCode(int rawCode)Set the rawCode value in this event.-
Methods inherited from class com.github.kwhat.jnativehook.NativeInputEvent
getID, getModifiers, getModifiersText, getWhen, setModifiers
-
Methods inherited from class java.util.EventObject
getSource, toString
-
-
-
-
Field Detail
-
NATIVE_KEY_FIRST
public static final int NATIVE_KEY_FIRST
The first number in the range of ID's used for native key events.- See Also:
- Constant Field Values
-
NATIVE_KEY_LAST
public static final int NATIVE_KEY_LAST
The last number in the range of ID's used for native key events.- See Also:
- Constant Field Values
-
NATIVE_KEY_TYPED
public static final int NATIVE_KEY_TYPED
The "native key typed" event ID.- See Also:
- Constant Field Values
-
NATIVE_KEY_PRESSED
public static final int NATIVE_KEY_PRESSED
The "native key pressed" event ID.- See Also:
- Constant Field Values
-
NATIVE_KEY_RELEASED
public static final int NATIVE_KEY_RELEASED
The "native key released" event ID.- See Also:
- Constant Field Values
-
KEY_LOCATION_UNKNOWN
public static final int KEY_LOCATION_UNKNOWN
- See Also:
- Constant Field Values
-
KEY_LOCATION_STANDARD
public static final int KEY_LOCATION_STANDARD
- See Also:
- Constant Field Values
-
KEY_LOCATION_LEFT
public static final int KEY_LOCATION_LEFT
- See Also:
- Constant Field Values
-
KEY_LOCATION_RIGHT
public static final int KEY_LOCATION_RIGHT
- See Also:
- Constant Field Values
-
KEY_LOCATION_NUMPAD
public static final int KEY_LOCATION_NUMPAD
- See Also:
- Constant Field Values
-
VC_ESCAPE
public static final int VC_ESCAPE
- See Also:
- Constant Field Values
-
VC_F1
public static final int VC_F1
Constants for the F1 through F24 function keys.- See Also:
- Constant Field Values
-
VC_F2
public static final int VC_F2
- See Also:
- Constant Field Values
-
VC_F3
public static final int VC_F3
- See Also:
- Constant Field Values
-
VC_F4
public static final int VC_F4
- See Also:
- Constant Field Values
-
VC_F5
public static final int VC_F5
- See Also:
- Constant Field Values
-
VC_F6
public static final int VC_F6
- See Also:
- Constant Field Values
-
VC_F7
public static final int VC_F7
- See Also:
- Constant Field Values
-
VC_F8
public static final int VC_F8
- See Also:
- Constant Field Values
-
VC_F9
public static final int VC_F9
- See Also:
- Constant Field Values
-
VC_F10
public static final int VC_F10
- See Also:
- Constant Field Values
-
VC_F11
public static final int VC_F11
- See Also:
- Constant Field Values
-
VC_F12
public static final int VC_F12
- See Also:
- Constant Field Values
-
VC_F13
public static final int VC_F13
- See Also:
- Constant Field Values
-
VC_F14
public static final int VC_F14
- See Also:
- Constant Field Values
-
VC_F15
public static final int VC_F15
- See Also:
- Constant Field Values
-
VC_F16
public static final int VC_F16
- See Also:
- Constant Field Values
-
VC_F17
public static final int VC_F17
- See Also:
- Constant Field Values
-
VC_F18
public static final int VC_F18
- See Also:
- Constant Field Values
-
VC_F19
public static final int VC_F19
- See Also:
- Constant Field Values
-
VC_F20
public static final int VC_F20
- See Also:
- Constant Field Values
-
VC_F21
public static final int VC_F21
- See Also:
- Constant Field Values
-
VC_F22
public static final int VC_F22
- See Also:
- Constant Field Values
-
VC_F23
public static final int VC_F23
- See Also:
- Constant Field Values
-
VC_F24
public static final int VC_F24
- See Also:
- Constant Field Values
-
VC_BACKQUOTE
public static final int VC_BACKQUOTE
- See Also:
- Constant Field Values
-
VC_1
public static final int VC_1
VC_0 thru VC_9- See Also:
- Constant Field Values
-
VC_2
public static final int VC_2
- See Also:
- Constant Field Values
-
VC_3
public static final int VC_3
- See Also:
- Constant Field Values
-
VC_4
public static final int VC_4
- See Also:
- Constant Field Values
-
VC_5
public static final int VC_5
- See Also:
- Constant Field Values
-
VC_6
public static final int VC_6
- See Also:
- Constant Field Values
-
VC_7
public static final int VC_7
- See Also:
- Constant Field Values
-
VC_8
public static final int VC_8
- See Also:
- Constant Field Values
-
VC_9
public static final int VC_9
- See Also:
- Constant Field Values
-
VC_0
public static final int VC_0
- See Also:
- Constant Field Values
-
VC_MINUS
public static final int VC_MINUS
- See Also:
- Constant Field Values
-
VC_EQUALS
public static final int VC_EQUALS
- See Also:
- Constant Field Values
-
VC_BACKSPACE
public static final int VC_BACKSPACE
- See Also:
- Constant Field Values
-
VC_TAB
public static final int VC_TAB
- See Also:
- Constant Field Values
-
VC_CAPS_LOCK
public static final int VC_CAPS_LOCK
- See Also:
- Constant Field Values
-
VC_A
public static final int VC_A
VC_A thru VC_Z- See Also:
- Constant Field Values
-
VC_B
public static final int VC_B
- See Also:
- Constant Field Values
-
VC_C
public static final int VC_C
- See Also:
- Constant Field Values
-
VC_D
public static final int VC_D
- See Also:
- Constant Field Values
-
VC_E
public static final int VC_E
- See Also:
- Constant Field Values
-
VC_F
public static final int VC_F
- See Also:
- Constant Field Values
-
VC_G
public static final int VC_G
- See Also:
- Constant Field Values
-
VC_H
public static final int VC_H
- See Also:
- Constant Field Values
-
VC_I
public static final int VC_I
- See Also:
- Constant Field Values
-
VC_J
public static final int VC_J
- See Also:
- Constant Field Values
-
VC_K
public static final int VC_K
- See Also:
- Constant Field Values
-
VC_L
public static final int VC_L
- See Also:
- Constant Field Values
-
VC_M
public static final int VC_M
- See Also:
- Constant Field Values
-
VC_N
public static final int VC_N
- See Also:
- Constant Field Values
-
VC_O
public static final int VC_O
- See Also:
- Constant Field Values
-
VC_P
public static final int VC_P
- See Also:
- Constant Field Values
-
VC_Q
public static final int VC_Q
- See Also:
- Constant Field Values
-
VC_R
public static final int VC_R
- See Also:
- Constant Field Values
-
VC_S
public static final int VC_S
- See Also:
- Constant Field Values
-
VC_T
public static final int VC_T
- See Also:
- Constant Field Values
-
VC_U
public static final int VC_U
- See Also:
- Constant Field Values
-
VC_V
public static final int VC_V
- See Also:
- Constant Field Values
-
VC_W
public static final int VC_W
- See Also:
- Constant Field Values
-
VC_X
public static final int VC_X
- See Also:
- Constant Field Values
-
VC_Y
public static final int VC_Y
- See Also:
- Constant Field Values
-
VC_Z
public static final int VC_Z
- See Also:
- Constant Field Values
-
VC_OPEN_BRACKET
public static final int VC_OPEN_BRACKET
- See Also:
- Constant Field Values
-
VC_CLOSE_BRACKET
public static final int VC_CLOSE_BRACKET
- See Also:
- Constant Field Values
-
VC_BACK_SLASH
public static final int VC_BACK_SLASH
- See Also:
- Constant Field Values
-
VC_SEMICOLON
public static final int VC_SEMICOLON
- See Also:
- Constant Field Values
-
VC_QUOTE
public static final int VC_QUOTE
- See Also:
- Constant Field Values
-
VC_ENTER
public static final int VC_ENTER
- See Also:
- Constant Field Values
-
VC_COMMA
public static final int VC_COMMA
- See Also:
- Constant Field Values
-
VC_PERIOD
public static final int VC_PERIOD
- See Also:
- Constant Field Values
-
VC_SLASH
public static final int VC_SLASH
- See Also:
- Constant Field Values
-
VC_SPACE
public static final int VC_SPACE
- See Also:
- Constant Field Values
-
VC_PRINTSCREEN
public static final int VC_PRINTSCREEN
- See Also:
- Constant Field Values
-
VC_SCROLL_LOCK
public static final int VC_SCROLL_LOCK
- See Also:
- Constant Field Values
-
VC_PAUSE
public static final int VC_PAUSE
- See Also:
- Constant Field Values
-
VC_INSERT
public static final int VC_INSERT
Edit Key Zone- See Also:
- Constant Field Values
-
VC_DELETE
public static final int VC_DELETE
- See Also:
- Constant Field Values
-
VC_HOME
public static final int VC_HOME
- See Also:
- Constant Field Values
-
VC_END
public static final int VC_END
- See Also:
- Constant Field Values
-
VC_PAGE_UP
public static final int VC_PAGE_UP
- See Also:
- Constant Field Values
-
VC_PAGE_DOWN
public static final int VC_PAGE_DOWN
- See Also:
- Constant Field Values
-
VC_UP
public static final int VC_UP
Begin Cursor Key Zone- See Also:
- Constant Field Values
-
VC_LEFT
public static final int VC_LEFT
- See Also:
- Constant Field Values
-
VC_CLEAR
public static final int VC_CLEAR
- See Also:
- Constant Field Values
-
VC_RIGHT
public static final int VC_RIGHT
- See Also:
- Constant Field Values
-
VC_DOWN
public static final int VC_DOWN
- See Also:
- Constant Field Values
-
VC_NUM_LOCK
public static final int VC_NUM_LOCK
Begin Numeric Zone- See Also:
- Constant Field Values
-
VC_SEPARATOR
public static final int VC_SEPARATOR
- See Also:
- Constant Field Values
-
VC_SHIFT
public static final int VC_SHIFT
Modifier and Control Keys- See Also:
- Constant Field Values
-
VC_CONTROL
public static final int VC_CONTROL
- See Also:
- Constant Field Values
-
VC_ALT
public static final int VC_ALT
- See Also:
- Constant Field Values
-
VC_META
public static final int VC_META
- See Also:
- Constant Field Values
-
VC_CONTEXT_MENU
public static final int VC_CONTEXT_MENU
- See Also:
- Constant Field Values
-
VC_POWER
public static final int VC_POWER
Media and Extra Keys- See Also:
- Constant Field Values
-
VC_SLEEP
public static final int VC_SLEEP
- See Also:
- Constant Field Values
-
VC_WAKE
public static final int VC_WAKE
- See Also:
- Constant Field Values
-
VC_MEDIA_PLAY
public static final int VC_MEDIA_PLAY
- See Also:
- Constant Field Values
-
VC_MEDIA_STOP
public static final int VC_MEDIA_STOP
- See Also:
- Constant Field Values
-
VC_MEDIA_PREVIOUS
public static final int VC_MEDIA_PREVIOUS
- See Also:
- Constant Field Values
-
VC_MEDIA_NEXT
public static final int VC_MEDIA_NEXT
- See Also:
- Constant Field Values
-
VC_MEDIA_SELECT
public static final int VC_MEDIA_SELECT
- See Also:
- Constant Field Values
-
VC_MEDIA_EJECT
public static final int VC_MEDIA_EJECT
- See Also:
- Constant Field Values
-
VC_VOLUME_MUTE
public static final int VC_VOLUME_MUTE
- See Also:
- Constant Field Values
-
VC_VOLUME_UP
public static final int VC_VOLUME_UP
- See Also:
- Constant Field Values
-
VC_VOLUME_DOWN
public static final int VC_VOLUME_DOWN
- See Also:
- Constant Field Values
-
VC_APP_MAIL
public static final int VC_APP_MAIL
- See Also:
- Constant Field Values
-
VC_APP_CALCULATOR
public static final int VC_APP_CALCULATOR
- See Also:
- Constant Field Values
-
VC_APP_MUSIC
public static final int VC_APP_MUSIC
- See Also:
- Constant Field Values
-
VC_APP_PICTURES
public static final int VC_APP_PICTURES
- See Also:
- Constant Field Values
-
VC_BROWSER_SEARCH
public static final int VC_BROWSER_SEARCH
- See Also:
- Constant Field Values
-
VC_BROWSER_HOME
public static final int VC_BROWSER_HOME
- See Also:
- Constant Field Values
-
VC_BROWSER_BACK
public static final int VC_BROWSER_BACK
- See Also:
- Constant Field Values
-
VC_BROWSER_FORWARD
public static final int VC_BROWSER_FORWARD
- See Also:
- Constant Field Values
-
VC_BROWSER_STOP
public static final int VC_BROWSER_STOP
- See Also:
- Constant Field Values
-
VC_BROWSER_REFRESH
public static final int VC_BROWSER_REFRESH
- See Also:
- Constant Field Values
-
VC_BROWSER_FAVORITES
public static final int VC_BROWSER_FAVORITES
- See Also:
- Constant Field Values
-
VC_KATAKANA
public static final int VC_KATAKANA
Japanese Language Keys- See Also:
- Constant Field Values
-
VC_UNDERSCORE
public static final int VC_UNDERSCORE
- See Also:
- Constant Field Values
-
VC_FURIGANA
public static final int VC_FURIGANA
- See Also:
- Constant Field Values
-
VC_KANJI
public static final int VC_KANJI
- See Also:
- Constant Field Values
-
VC_HIRAGANA
public static final int VC_HIRAGANA
- See Also:
- Constant Field Values
-
VC_YEN
public static final int VC_YEN
- See Also:
- Constant Field Values
-
VC_SUN_HELP
public static final int VC_SUN_HELP
Sun keyboards- See Also:
- Constant Field Values
-
VC_SUN_STOP
public static final int VC_SUN_STOP
- See Also:
- Constant Field Values
-
VC_SUN_PROPS
public static final int VC_SUN_PROPS
- See Also:
- Constant Field Values
-
VC_SUN_FRONT
public static final int VC_SUN_FRONT
- See Also:
- Constant Field Values
-
VC_SUN_OPEN
public static final int VC_SUN_OPEN
- See Also:
- Constant Field Values
-
VC_SUN_FIND
public static final int VC_SUN_FIND
- See Also:
- Constant Field Values
-
VC_SUN_AGAIN
public static final int VC_SUN_AGAIN
- See Also:
- Constant Field Values
-
VC_SUN_UNDO
public static final int VC_SUN_UNDO
- See Also:
- Constant Field Values
-
VC_SUN_COPY
public static final int VC_SUN_COPY
- See Also:
- Constant Field Values
-
VC_SUN_INSERT
public static final int VC_SUN_INSERT
- See Also:
- Constant Field Values
-
VC_SUN_CUT
public static final int VC_SUN_CUT
- See Also:
- Constant Field Values
-
VC_UNDEFINED
public static final int VC_UNDEFINED
This value is used to indicate that the keyCode is unknown.- See Also:
- Constant Field Values
-
CHAR_UNDEFINED
public static final char CHAR_UNDEFINED
This is used to indicate that the keyChar is undefined.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NativeKeyEvent
public NativeKeyEvent(int id, int modifiers, int rawCode, int keyCode, char keyChar, int keyLocation)Instantiates a new native key event.Note that passing in an invalid ID results in unspecified behavior.
- Parameters:
id- an integer that identifies the native event type.modifiers- the modifier mask for the native event.NativeInputEvent_MASK modifiers should be used as they are not compatible with AWT'sInputEvent_DOWN_MASK or the older _MASK modifiers.rawCode- the hardware code associated with the native key in this event.keyCode- the virtual key code generated by this event, or VC_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- the location ID of the key generating this event.- Since:
- 1.1
-
NativeKeyEvent
public NativeKeyEvent(int id, int modifiers, int rawCode, int keyCode, char keyChar)Instantiates a new native key event.Note that passing in an invalid ID results in unspecified behavior.
- Parameters:
id- an integer that identifies the native event type.modifiers- the modifier mask for the native event.NativeInputEvent_MASK modifiers should be used as they are not compatible with AWT'sInputEvent_DOWN_MASK or the older _MASK modifiers.rawCode- the hardware code associated with the native key in this event.keyCode- the virtual key code generated by this event, or VC_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).- Since:
- 1.1
-
-
Method Detail
-
getRawCode
public int getRawCode()
Returns the native code associated with the native key in this event. This is an arbitrary number between 0 and 255 (inclusive) used by the operating system to represent a physical key on the keyboard. This code does not necessarily represent the native key's scan code or ASCII representation. To maintain platform independence, you should not rely on the consistency of this value from platform to platform.- Returns:
- the native key code for this event.
-
setRawCode
public void setRawCode(int rawCode)
Set the rawCode value in this event. For more information on what this value represents, please seegetRawCode().- Parameters:
rawCode- the native key code for this event.
-
getKeyCode
public int getKeyCode()
Returns the keyCode associated with this event. Note, this method will always returnVC_UNDEFINEDfor theNATIVE_KEY_TYPEDevent types.- Returns:
- the native virtual key code.
-
setKeyCode
public void setKeyCode(int keyCode)
Set the keyCode value in this event.- Parameters:
keyCode- the native virtual key code.
-
getKeyChar
public char getKeyChar()
Returns the native Unicode character associated with this event. Note, this method will always returnCHAR_UNDEFINEDforNATIVE_KEY_PRESSEDandNATIVE_KEY_RELEASEDevent types.- Returns:
- the Unicode character defined for this key event. If no valid Unicode character
exists for this key event,
CHAR_UNDEFINEDis returned.
-
setKeyChar
public void setKeyChar(char keyChar)
Set the keyChar value in this event. For example, theNATIVE_KEY_TYPEDevent for Shift + "a" returns the Unicode value 'A'.- Parameters:
keyChar- the keyboard character associated with this event.
-
getKeyLocation
public int getKeyLocation()
Returns the location of the virtual key for this event.- Returns:
- the location of the virtual key that was pressed or released.
-
getKeyText
public static String getKeyText(int keyCode)
Returns a String describing the keyCode, such as "HOME", "F1" or "A". These strings can be localized by changing the awt.properties file.- Parameters:
keyCode- the native virtual key code generated by this event- Returns:
- a string containing a text description for a physical key, identified by its keyCode.
-
isActionKey
public boolean isActionKey()
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:
trueif the key is an "action" key,falseotherwise.- Since:
- 1.1
-
paramString
public String paramString()
Returns a parameter string identifying this event. This method is useful for event logging and debugging.- Overrides:
paramStringin classNativeInputEvent- Returns:
- a string identifying the event and its attributes.
-
-