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
NativeKeyListener
object which has been registered to receive global key events using theGlobalScreen.addNativeKeyListener(NativeKeyListener)
method. EachNativeKeyListener
object will receive aNativeKeyEvent
when the event occurs.All
NativeKeyEvent
objects are dependent on the native platform and keyboard layout.NATIVE_KEY_PRESSED
andNATIVE_KEY_RELEASED
events 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_PRESSED
andNATIVE_KEY_RELEASED
will always returnCHAR_UNDEFINED
.NATIVE_KEY_TYPED
events are produced forNATIVE_KEY_PRESSED
events 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_UNDEFINED
forNATIVE_KEY_TYPED
events.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_PRESSED
andNATIVE_KEY_RELEASED
events should only be used to determin phisical key state, whileNATIVE_KEY_TYPED
events 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 char
CHAR_UNDEFINED
This is used to indicate that the keyChar is undefined.static int
KEY_LOCATION_LEFT
static int
KEY_LOCATION_NUMPAD
static int
KEY_LOCATION_RIGHT
static int
KEY_LOCATION_STANDARD
static int
KEY_LOCATION_UNKNOWN
static int
NATIVE_KEY_FIRST
The first number in the range of ID's used for native key events.static int
NATIVE_KEY_LAST
The last number in the range of ID's used for native key events.static int
NATIVE_KEY_PRESSED
The "native key pressed" event ID.static int
NATIVE_KEY_RELEASED
The "native key released" event ID.static int
NATIVE_KEY_TYPED
The "native key typed" event ID.static int
VC_0
static int
VC_1
VC_0 thru VC_9static int
VC_2
static int
VC_3
static int
VC_4
static int
VC_5
static int
VC_6
static int
VC_7
static int
VC_8
static int
VC_9
static int
VC_A
VC_A thru VC_Zstatic int
VC_ALT
static int
VC_APP_CALCULATOR
static int
VC_APP_MAIL
static int
VC_APP_MUSIC
static int
VC_APP_PICTURES
static int
VC_B
static int
VC_BACK_SLASH
static int
VC_BACKQUOTE
static int
VC_BACKSPACE
static int
VC_BROWSER_BACK
static int
VC_BROWSER_FAVORITES
static int
VC_BROWSER_FORWARD
static int
VC_BROWSER_HOME
static int
VC_BROWSER_REFRESH
static int
VC_BROWSER_SEARCH
static int
VC_BROWSER_STOP
static int
VC_C
static int
VC_CAPS_LOCK
static int
VC_CLEAR
static int
VC_CLOSE_BRACKET
static int
VC_COMMA
static int
VC_CONTEXT_MENU
static int
VC_CONTROL
static int
VC_D
static int
VC_DELETE
static int
VC_DOWN
static int
VC_E
static int
VC_END
static int
VC_ENTER
static int
VC_EQUALS
static int
VC_ESCAPE
static int
VC_F
static int
VC_F1
Constants for the F1 through F24 function keys.static int
VC_F10
static int
VC_F11
static int
VC_F12
static int
VC_F13
static int
VC_F14
static int
VC_F15
static int
VC_F16
static int
VC_F17
static int
VC_F18
static int
VC_F19
static int
VC_F2
static int
VC_F20
static int
VC_F21
static int
VC_F22
static int
VC_F23
static int
VC_F24
static int
VC_F3
static int
VC_F4
static int
VC_F5
static int
VC_F6
static int
VC_F7
static int
VC_F8
static int
VC_F9
static int
VC_FURIGANA
static int
VC_G
static int
VC_H
static int
VC_HIRAGANA
static int
VC_HOME
static int
VC_I
static int
VC_INSERT
Edit Key Zonestatic int
VC_J
static int
VC_K
static int
VC_KANJI
static int
VC_KATAKANA
Japanese Language Keysstatic int
VC_L
static int
VC_LEFT
static int
VC_M
static int
VC_MEDIA_EJECT
static int
VC_MEDIA_NEXT
static int
VC_MEDIA_PLAY
static int
VC_MEDIA_PREVIOUS
static int
VC_MEDIA_SELECT
static int
VC_MEDIA_STOP
static int
VC_META
static int
VC_MINUS
static int
VC_N
static int
VC_NUM_LOCK
Begin Numeric Zonestatic int
VC_O
static int
VC_OPEN_BRACKET
static int
VC_P
static int
VC_PAGE_DOWN
static int
VC_PAGE_UP
static int
VC_PAUSE
static int
VC_PERIOD
static int
VC_POWER
Media and Extra Keysstatic int
VC_PRINTSCREEN
static int
VC_Q
static int
VC_QUOTE
static int
VC_R
static int
VC_RIGHT
static int
VC_S
static int
VC_SCROLL_LOCK
static int
VC_SEMICOLON
static int
VC_SEPARATOR
static int
VC_SHIFT
Modifier and Control Keysstatic int
VC_SLASH
static int
VC_SLEEP
static int
VC_SPACE
static int
VC_SUN_AGAIN
static int
VC_SUN_COPY
static int
VC_SUN_CUT
static int
VC_SUN_FIND
static int
VC_SUN_FRONT
static int
VC_SUN_HELP
Sun keyboardsstatic int
VC_SUN_INSERT
static int
VC_SUN_OPEN
static int
VC_SUN_PROPS
static int
VC_SUN_STOP
static int
VC_SUN_UNDO
static int
VC_T
static int
VC_TAB
static int
VC_U
static int
VC_UNDEFINED
This value is used to indicate that the keyCode is unknown.static int
VC_UNDERSCORE
static int
VC_UP
Begin Cursor Key Zonestatic int
VC_V
static int
VC_VOLUME_DOWN
static int
VC_VOLUME_MUTE
static int
VC_VOLUME_UP
static int
VC_W
static int
VC_WAKE
static int
VC_X
static int
VC_Y
static int
VC_YEN
static int
VC_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 char
getKeyChar()
Returns the native Unicode character associated with this event.int
getKeyCode()
Returns the keyCode associated with this event.int
getKeyLocation()
Returns the location of the virtual key for this event.static String
getKeyText(int keyCode)
Returns a String describing the keyCode, such as "HOME", "F1" or "A".int
getRawCode()
Returns the native code associated with the native key in this event.boolean
isActionKey()
Returns whether the key in this event is an "action" key.String
paramString()
Returns a parameter string identifying this event.void
setKeyChar(char keyChar)
Set the keyChar value in this event.void
setKeyCode(int keyCode)
Set the keyCode value in this event.void
setRawCode(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_UNDEFINED
for theNATIVE_KEY_TYPED
event 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_UNDEFINED
forNATIVE_KEY_PRESSED
andNATIVE_KEY_RELEASED
event types.- Returns:
- the Unicode character defined for this key event. If no valid Unicode character
exists for this key event,
CHAR_UNDEFINED
is returned.
-
setKeyChar
public void setKeyChar(char keyChar)
Set the keyChar value in this event. For example, theNATIVE_KEY_TYPED
event 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:
true
if the key is an "action" key,false
otherwise.- Since:
- 1.1
-
paramString
public String paramString()
Returns a parameter string identifying this event. This method is useful for event logging and debugging.- Overrides:
paramString
in classNativeInputEvent
- Returns:
- a string identifying the event and its attributes.
-
-