public class NativeKeyEvent extends NativeInputEvent
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 the GlobalScreen.addNativeKeyListener(NativeKeyListener)
method. Each NativeKeyListener
object will receive a
NativeKeyEvent
when the event occurs.
All NativeKeyEvent
objects are dependent on the native platform and
keyboard layout. NATIVE_KEY_PRESSED
and NATIVE_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 or
VC_UNDEFINED
. Please note that getKeyChar()
for events of type
NATIVE_KEY_PRESSED
and NATIVE_KEY_RELEASED
will always return
CHAR_UNDEFINED
.
NATIVE_KEY_TYPED
events are produced for NATIVE_KEY_PRESSED
events that produce valid Unicode characters for the current keyboard layout. The
getKeyChar()
method always returns a valid Unicode character for this type of
event. Please note that getKeyCode()
will always return VC_UNDEFINED
for NATIVE_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
and NATIVE_KEY_RELEASED
events
should only be used to determin phisical key state, while NATIVE_KEY_TYPED
events can be used to determine the Unicode representation of the NativeKeyEvent
.
GlobalScreen
,
NativeKeyListener
,
Serialized FormModifier and Type | Field and 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_9
|
static 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_Z
|
static 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 Zone
|
static int |
VC_J |
static int |
VC_K |
static int |
VC_KANJI |
static int |
VC_KATAKANA
Japanese Language Keys
|
static 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 Zone
|
static 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 Keys
|
static 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 Keys
|
static 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 keyboards
|
static 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 Zone
|
static 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 |
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
source
Constructor and 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.
|
Modifier and Type | Method and 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.
|
getID, getModifiers, getModifiersText, getWhen, setModifiers
getSource, toString
public static final int NATIVE_KEY_FIRST
public static final int NATIVE_KEY_LAST
public static final int NATIVE_KEY_TYPED
public static final int NATIVE_KEY_PRESSED
public static final int NATIVE_KEY_RELEASED
public static final int KEY_LOCATION_UNKNOWN
public static final int KEY_LOCATION_STANDARD
public static final int KEY_LOCATION_LEFT
public static final int KEY_LOCATION_RIGHT
public static final int KEY_LOCATION_NUMPAD
public static final int VC_ESCAPE
public static final int VC_F1
public static final int VC_F2
public static final int VC_F3
public static final int VC_F4
public static final int VC_F5
public static final int VC_F6
public static final int VC_F7
public static final int VC_F8
public static final int VC_F9
public static final int VC_F10
public static final int VC_F11
public static final int VC_F12
public static final int VC_F13
public static final int VC_F14
public static final int VC_F15
public static final int VC_F16
public static final int VC_F17
public static final int VC_F18
public static final int VC_F19
public static final int VC_F20
public static final int VC_F21
public static final int VC_F22
public static final int VC_F23
public static final int VC_F24
public static final int VC_BACKQUOTE
public static final int VC_1
public static final int VC_2
public static final int VC_3
public static final int VC_4
public static final int VC_5
public static final int VC_6
public static final int VC_7
public static final int VC_8
public static final int VC_9
public static final int VC_0
public static final int VC_MINUS
public static final int VC_EQUALS
public static final int VC_BACKSPACE
public static final int VC_TAB
public static final int VC_CAPS_LOCK
public static final int VC_A
public static final int VC_B
public static final int VC_C
public static final int VC_D
public static final int VC_E
public static final int VC_F
public static final int VC_G
public static final int VC_H
public static final int VC_I
public static final int VC_J
public static final int VC_K
public static final int VC_L
public static final int VC_M
public static final int VC_N
public static final int VC_O
public static final int VC_P
public static final int VC_Q
public static final int VC_R
public static final int VC_S
public static final int VC_T
public static final int VC_U
public static final int VC_V
public static final int VC_W
public static final int VC_X
public static final int VC_Y
public static final int VC_Z
public static final int VC_OPEN_BRACKET
public static final int VC_CLOSE_BRACKET
public static final int VC_BACK_SLASH
public static final int VC_SEMICOLON
public static final int VC_QUOTE
public static final int VC_ENTER
public static final int VC_COMMA
public static final int VC_PERIOD
public static final int VC_SLASH
public static final int VC_SPACE
public static final int VC_PRINTSCREEN
public static final int VC_SCROLL_LOCK
public static final int VC_PAUSE
public static final int VC_INSERT
public static final int VC_DELETE
public static final int VC_HOME
public static final int VC_END
public static final int VC_PAGE_UP
public static final int VC_PAGE_DOWN
public static final int VC_UP
public static final int VC_LEFT
public static final int VC_CLEAR
public static final int VC_RIGHT
public static final int VC_DOWN
public static final int VC_NUM_LOCK
public static final int VC_SEPARATOR
public static final int VC_SHIFT
public static final int VC_CONTROL
public static final int VC_ALT
public static final int VC_META
public static final int VC_CONTEXT_MENU
public static final int VC_POWER
public static final int VC_SLEEP
public static final int VC_WAKE
public static final int VC_MEDIA_PLAY
public static final int VC_MEDIA_STOP
public static final int VC_MEDIA_PREVIOUS
public static final int VC_MEDIA_NEXT
public static final int VC_MEDIA_SELECT
public static final int VC_MEDIA_EJECT
public static final int VC_VOLUME_MUTE
public static final int VC_VOLUME_UP
public static final int VC_VOLUME_DOWN
public static final int VC_APP_MAIL
public static final int VC_APP_CALCULATOR
public static final int VC_APP_MUSIC
public static final int VC_APP_PICTURES
public static final int VC_BROWSER_SEARCH
public static final int VC_BROWSER_HOME
public static final int VC_BROWSER_BACK
public static final int VC_BROWSER_FORWARD
public static final int VC_BROWSER_STOP
public static final int VC_BROWSER_REFRESH
public static final int VC_BROWSER_FAVORITES
public static final int VC_KATAKANA
public static final int VC_UNDERSCORE
public static final int VC_FURIGANA
public static final int VC_KANJI
public static final int VC_HIRAGANA
public static final int VC_YEN
public static final int VC_SUN_HELP
public static final int VC_SUN_STOP
public static final int VC_SUN_PROPS
public static final int VC_SUN_FRONT
public static final int VC_SUN_OPEN
public static final int VC_SUN_FIND
public static final int VC_SUN_AGAIN
public static final int VC_SUN_UNDO
public static final int VC_SUN_COPY
public static final int VC_SUN_INSERT
public static final int VC_SUN_CUT
public static final int VC_UNDEFINED
public static final char CHAR_UNDEFINED
public NativeKeyEvent(int id, int modifiers, int rawCode, int keyCode, char keyChar, int keyLocation)
Note that passing in an invalid ID results in unspecified behavior.
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's InputEvent
_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.public NativeKeyEvent(int id, int modifiers, int rawCode, int keyCode, char keyChar)
Note that passing in an invalid ID results in unspecified behavior.
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's InputEvent
_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).public int getRawCode()
public void setRawCode(int rawCode)
getRawCode()
.rawCode
- the native key code for this event.public int getKeyCode()
VC_UNDEFINED
for the
NATIVE_KEY_TYPED
event types.public void setKeyCode(int keyCode)
keyCode
- the native virtual key code.public char getKeyChar()
CHAR_UNDEFINED
for
NATIVE_KEY_PRESSED
and NATIVE_KEY_RELEASED
event types.CHAR_UNDEFINED
is returned.public void setKeyChar(char keyChar)
NATIVE_KEY_TYPED
event for Shift + "a" returns the Unicode
value 'A'.keyChar
- the keyboard character associated with this event.public int getKeyLocation()
public static String getKeyText(int keyCode)
keyCode
- the native virtual key code generated by this eventpublic boolean isActionKey()
true
if the key is an "action" key,
false
otherwise.public String paramString()
paramString
in class NativeInputEvent
Copyright © 2006-2017 ${project.vendor}. All Rights Received.