Build 1.1_r1 (from source)

android.view
Class KeyEvent

java.lang.Object
  extended by android.view.KeyEvent
All Implemented Interfaces:
Parcelable

public class KeyEvent
extends Object
implements Parcelable

Contains constants for key events.


Nested Class Summary
static interface KeyEvent.Callback
           
 
Nested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.Creator<T>
 
Field Summary
static int ACTION_DOWN
          getAction() value: the key has been pressed down.
static int ACTION_MULTIPLE
          getAction() value: multiple duplicate key events have occurred in a row.
static int ACTION_UP
          getAction() value: the key has been released.
static Parcelable.Creator<KeyEvent> CREATOR
           
static int FLAG_SOFT_KEYBOARD
          This mask is set if the key event was generated by a software keyboard.
static int FLAG_WOKE_HERE
          This mask is set if the device woke because of this key event.
static int KEYCODE_0
           
static int KEYCODE_1
           
static int KEYCODE_2
           
static int KEYCODE_3
           
static int KEYCODE_4
           
static int KEYCODE_5
           
static int KEYCODE_6
           
static int KEYCODE_7
           
static int KEYCODE_8
           
static int KEYCODE_9
           
static int KEYCODE_A
           
static int KEYCODE_ALT_LEFT
           
static int KEYCODE_ALT_RIGHT
           
static int KEYCODE_APOSTROPHE
           
static int KEYCODE_AT
           
static int KEYCODE_B
           
static int KEYCODE_BACK
           
static int KEYCODE_BACKSLASH
           
static int KEYCODE_C
           
static int KEYCODE_CALL
           
static int KEYCODE_CAMERA
           
static int KEYCODE_CLEAR
           
static int KEYCODE_COMMA
           
static int KEYCODE_D
           
static int KEYCODE_DEL
           
static int KEYCODE_DPAD_CENTER
           
static int KEYCODE_DPAD_DOWN
           
static int KEYCODE_DPAD_LEFT
           
static int KEYCODE_DPAD_RIGHT
           
static int KEYCODE_DPAD_UP
           
static int KEYCODE_E
           
static int KEYCODE_ENDCALL
           
static int KEYCODE_ENTER
           
static int KEYCODE_ENVELOPE
           
static int KEYCODE_EQUALS
           
static int KEYCODE_EXPLORER
           
static int KEYCODE_F
           
static int KEYCODE_FOCUS
           
static int KEYCODE_FORWARD
           
static int KEYCODE_G
           
static int KEYCODE_GRAVE
           
static int KEYCODE_H
           
static int KEYCODE_HEADSETHOOK
           
static int KEYCODE_HOME
           
static int KEYCODE_I
           
static int KEYCODE_J
           
static int KEYCODE_K
           
static int KEYCODE_L
           
static int KEYCODE_LEFT_BRACKET
           
static int KEYCODE_M
           
static int KEYCODE_MENU
           
static int KEYCODE_MINUS
           
static int KEYCODE_N
           
static int KEYCODE_NEXTSONG
           
static int KEYCODE_NOTIFICATION
           
static int KEYCODE_NUM
           
static int KEYCODE_O
           
static int KEYCODE_P
           
static int KEYCODE_PERIOD
           
static int KEYCODE_PLAYPAUSE
           
static int KEYCODE_PLUS
           
static int KEYCODE_POUND
           
static int KEYCODE_POWER
           
static int KEYCODE_PREVIOUSSONG
           
static int KEYCODE_Q
           
static int KEYCODE_R
           
static int KEYCODE_REWIND
           
static int KEYCODE_RIGHT_BRACKET
           
static int KEYCODE_S
           
static int KEYCODE_SEARCH
           
static int KEYCODE_SEMICOLON
           
static int KEYCODE_SHIFT_LEFT
           
static int KEYCODE_SHIFT_RIGHT
           
static int KEYCODE_SLASH
           
static int KEYCODE_SOFT_LEFT
           
static int KEYCODE_SOFT_RIGHT
           
static int KEYCODE_SPACE
           
static int KEYCODE_STAR
           
static int KEYCODE_STOP
           
static int KEYCODE_SYM
           
static int KEYCODE_T
           
static int KEYCODE_TAB
           
static int KEYCODE_U
           
static int KEYCODE_UNKNOWN
           
static int KEYCODE_V
           
static int KEYCODE_VOLUME_DOWN
           
static int KEYCODE_VOLUME_UP
           
static int KEYCODE_W
           
static int KEYCODE_X
           
static int KEYCODE_Y
           
static int KEYCODE_Z
           
static int MAX_KEYCODE
          Deprecated. There are now more than MAX_KEYCODE keycodes. Use getMaxKeyCode() instead.
static int META_ALT_LEFT_ON
          This mask is used to check whether the left ALT meta key is pressed.
static int META_ALT_ON
          This mask is used to check whether one of the ALT meta keys is pressed.
static int META_ALT_RIGHT_ON
          This mask is used to check whether the right the ALT meta key is pressed.
static int META_SHIFT_LEFT_ON
          This mask is used to check whether the left SHIFT meta key is pressed.
static int META_SHIFT_ON
          This mask is used to check whether one of the SHIFT meta keys is pressed.
static int META_SHIFT_RIGHT_ON
          This mask is used to check whether the right SHIFT meta key is pressed.
static int META_SYM_ON
          This mask is used to check whether the SYM meta key is pressed.
 
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
 
Constructor Summary
KeyEvent(int action, int code)
          Create a new key event.
KeyEvent(KeyEvent origEvent, int action)
          Copy an existing key event, modifying its action.
KeyEvent(KeyEvent origEvent, long eventTime, int newRepeat)
          Copy an existing key event, modifying its time and repeat count.
KeyEvent(long downTime, long eventTime, int action, int code, int repeat)
          Create a new key event.
KeyEvent(long downTime, long eventTime, int action, int code, int repeat, int metaState)
          Create a new key event.
KeyEvent(long downTime, long eventTime, int action, int code, int repeat, int metaState, int device, int scancode)
          Create a new key event.
KeyEvent(long downTime, long eventTime, int action, int code, int repeat, int metaState, int device, int scancode, int flags)
          Create a new key event.
 
Method Summary
 int describeContents()
          Describe the kinds of special objects contained in this Parcelable's marshalled representation.
 boolean dispatch(KeyEvent.Callback receiver)
          Deliver this key event to a KeyEvent.Callback interface.
 int getAction()
          Retrieve the action of this key event.
static int getDeadChar(int accent, int c)
          Get the character that is produced by putting accent on the character c.
 int getDeviceId()
          Return the id for the keyboard that this event came from.
 char getDisplayLabel()
          Get the primary character for this key.
 long getDownTime()
          Retrieve the time of the most recent key down event, in the SystemClock.uptimeMillis() time base.
 long getEventTime()
          Retrieve the time this event occurred, in the SystemClock.uptimeMillis() time base.
 int getFlags()
          Returns the flags for this key event.
 int getKeyboardDevice()
          Deprecated.  
 int getKeyCode()
          Retrieve the key code of the key event.
 boolean getKeyData(KeyCharacterMap.KeyData results)
          Get the characters conversion data for the key event..
 char getMatch(char[] chars)
          The same as getMatch(chars, 0).
 char getMatch(char[] chars, int modifiers)
          If one of the chars in the array can be generated by the keyCode of this key event, return the char; otherwise return '\0'.
static int getMaxKeyCode()
          Returns the maximum keycode.
 int getMetaState()
          Returns the state of the meta keys.
 char getNumber()
          Gets the number or symbol associated with the key.
 int getRepeatCount()
          Retrieve the repeat count of the event.
 int getScanCode()
          Retrieve the hardware key id of this key event.
 int getUnicodeChar()
           Returns the Unicode character that the key would produce.
 int getUnicodeChar(int meta)
           Returns the Unicode character that the key would produce.
 boolean isAltPressed()
          Returns the pressed state of the ALT meta key.
 boolean isDown()
          Deprecated.  
static boolean isModifierKey(int keyCode)
          Returns true if this key code is a modifier key.
 boolean isPrintingKey()
          Does the key code of this key produce a glyph?
 boolean isShiftPressed()
          Returns the pressed state of the SHIFT meta key.
 boolean isSymPressed()
          Returns the pressed state of the SYM meta key.
 boolean isSystem()
          Is this a system key? System keys can not be used for menu shortcuts.
 String toString()
          Returns a string containing a concise, human-readable description of this object.
 void writeToParcel(Parcel out, int flags)
          Flatten this object in to a Parcel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KEYCODE_UNKNOWN

public static final int KEYCODE_UNKNOWN
See Also:
Constant Field Values

KEYCODE_SOFT_LEFT

public static final int KEYCODE_SOFT_LEFT
See Also:
Constant Field Values

KEYCODE_SOFT_RIGHT

public static final int KEYCODE_SOFT_RIGHT
See Also:
Constant Field Values

KEYCODE_HOME

public static final int KEYCODE_HOME
See Also:
Constant Field Values

KEYCODE_BACK

public static final int KEYCODE_BACK
See Also:
Constant Field Values

KEYCODE_CALL

public static final int KEYCODE_CALL
See Also:
Constant Field Values

KEYCODE_ENDCALL

public static final int KEYCODE_ENDCALL
See Also:
Constant Field Values

KEYCODE_0

public static final int KEYCODE_0
See Also:
Constant Field Values

KEYCODE_1

public static final int KEYCODE_1
See Also:
Constant Field Values

KEYCODE_2

public static final int KEYCODE_2
See Also:
Constant Field Values

KEYCODE_3

public static final int KEYCODE_3
See Also:
Constant Field Values

KEYCODE_4

public static final int KEYCODE_4
See Also:
Constant Field Values

KEYCODE_5

public static final int KEYCODE_5
See Also:
Constant Field Values

KEYCODE_6

public static final int KEYCODE_6
See Also:
Constant Field Values

KEYCODE_7

public static final int KEYCODE_7
See Also:
Constant Field Values

KEYCODE_8

public static final int KEYCODE_8
See Also:
Constant Field Values

KEYCODE_9

public static final int KEYCODE_9
See Also:
Constant Field Values

KEYCODE_STAR

public static final int KEYCODE_STAR
See Also:
Constant Field Values

KEYCODE_POUND

public static final int KEYCODE_POUND
See Also:
Constant Field Values

KEYCODE_DPAD_UP

public static final int KEYCODE_DPAD_UP
See Also:
Constant Field Values

KEYCODE_DPAD_DOWN

public static final int KEYCODE_DPAD_DOWN
See Also:
Constant Field Values

KEYCODE_DPAD_LEFT

public static final int KEYCODE_DPAD_LEFT
See Also:
Constant Field Values

KEYCODE_DPAD_RIGHT

public static final int KEYCODE_DPAD_RIGHT
See Also:
Constant Field Values

KEYCODE_DPAD_CENTER

public static final int KEYCODE_DPAD_CENTER
See Also:
Constant Field Values

KEYCODE_VOLUME_UP

public static final int KEYCODE_VOLUME_UP
See Also:
Constant Field Values

KEYCODE_VOLUME_DOWN

public static final int KEYCODE_VOLUME_DOWN
See Also:
Constant Field Values

KEYCODE_POWER

public static final int KEYCODE_POWER
See Also:
Constant Field Values

KEYCODE_CAMERA

public static final int KEYCODE_CAMERA
See Also:
Constant Field Values

KEYCODE_CLEAR

public static final int KEYCODE_CLEAR
See Also:
Constant Field Values

KEYCODE_A

public static final int KEYCODE_A
See Also:
Constant Field Values

KEYCODE_B

public static final int KEYCODE_B
See Also:
Constant Field Values

KEYCODE_C

public static final int KEYCODE_C
See Also:
Constant Field Values

KEYCODE_D

public static final int KEYCODE_D
See Also:
Constant Field Values

KEYCODE_E

public static final int KEYCODE_E
See Also:
Constant Field Values

KEYCODE_F

public static final int KEYCODE_F
See Also:
Constant Field Values

KEYCODE_G

public static final int KEYCODE_G
See Also:
Constant Field Values

KEYCODE_H

public static final int KEYCODE_H
See Also:
Constant Field Values

KEYCODE_I

public static final int KEYCODE_I
See Also:
Constant Field Values

KEYCODE_J

public static final int KEYCODE_J
See Also:
Constant Field Values

KEYCODE_K

public static final int KEYCODE_K
See Also:
Constant Field Values

KEYCODE_L

public static final int KEYCODE_L
See Also:
Constant Field Values

KEYCODE_M

public static final int KEYCODE_M
See Also:
Constant Field Values

KEYCODE_N

public static final int KEYCODE_N
See Also:
Constant Field Values

KEYCODE_O

public static final int KEYCODE_O
See Also:
Constant Field Values

KEYCODE_P

public static final int KEYCODE_P
See Also:
Constant Field Values

KEYCODE_Q

public static final int KEYCODE_Q
See Also:
Constant Field Values

KEYCODE_R

public static final int KEYCODE_R
See Also:
Constant Field Values

KEYCODE_S

public static final int KEYCODE_S
See Also:
Constant Field Values

KEYCODE_T

public static final int KEYCODE_T
See Also:
Constant Field Values

KEYCODE_U

public static final int KEYCODE_U
See Also:
Constant Field Values

KEYCODE_V

public static final int KEYCODE_V
See Also:
Constant Field Values

KEYCODE_W

public static final int KEYCODE_W
See Also:
Constant Field Values

KEYCODE_X

public static final int KEYCODE_X
See Also:
Constant Field Values

KEYCODE_Y

public static final int KEYCODE_Y
See Also:
Constant Field Values

KEYCODE_Z

public static final int KEYCODE_Z
See Also:
Constant Field Values

KEYCODE_COMMA

public static final int KEYCODE_COMMA
See Also:
Constant Field Values

KEYCODE_PERIOD

public static final int KEYCODE_PERIOD
See Also:
Constant Field Values

KEYCODE_ALT_LEFT

public static final int KEYCODE_ALT_LEFT
See Also:
Constant Field Values

KEYCODE_ALT_RIGHT

public static final int KEYCODE_ALT_RIGHT
See Also:
Constant Field Values

KEYCODE_SHIFT_LEFT

public static final int KEYCODE_SHIFT_LEFT
See Also:
Constant Field Values

KEYCODE_SHIFT_RIGHT

public static final int KEYCODE_SHIFT_RIGHT
See Also:
Constant Field Values

KEYCODE_TAB

public static final int KEYCODE_TAB
See Also:
Constant Field Values

KEYCODE_SPACE

public static final int KEYCODE_SPACE
See Also:
Constant Field Values

KEYCODE_SYM

public static final int KEYCODE_SYM
See Also:
Constant Field Values

KEYCODE_EXPLORER

public static final int KEYCODE_EXPLORER
See Also:
Constant Field Values

KEYCODE_ENVELOPE

public static final int KEYCODE_ENVELOPE
See Also:
Constant Field Values

KEYCODE_ENTER

public static final int KEYCODE_ENTER
See Also:
Constant Field Values

KEYCODE_DEL

public static final int KEYCODE_DEL
See Also:
Constant Field Values

KEYCODE_GRAVE

public static final int KEYCODE_GRAVE
See Also:
Constant Field Values

KEYCODE_MINUS

public static final int KEYCODE_MINUS
See Also:
Constant Field Values

KEYCODE_EQUALS

public static final int KEYCODE_EQUALS
See Also:
Constant Field Values

KEYCODE_LEFT_BRACKET

public static final int KEYCODE_LEFT_BRACKET
See Also:
Constant Field Values

KEYCODE_RIGHT_BRACKET

public static final int KEYCODE_RIGHT_BRACKET
See Also:
Constant Field Values

KEYCODE_BACKSLASH

public static final int KEYCODE_BACKSLASH
See Also:
Constant Field Values

KEYCODE_SEMICOLON

public static final int KEYCODE_SEMICOLON
See Also:
Constant Field Values

KEYCODE_APOSTROPHE

public static final int KEYCODE_APOSTROPHE
See Also:
Constant Field Values

KEYCODE_SLASH

public static final int KEYCODE_SLASH
See Also:
Constant Field Values

KEYCODE_AT

public static final int KEYCODE_AT
See Also:
Constant Field Values

KEYCODE_NUM

public static final int KEYCODE_NUM
See Also:
Constant Field Values

KEYCODE_HEADSETHOOK

public static final int KEYCODE_HEADSETHOOK
See Also:
Constant Field Values

KEYCODE_FOCUS

public static final int KEYCODE_FOCUS
See Also:
Constant Field Values

KEYCODE_PLUS

public static final int KEYCODE_PLUS
See Also:
Constant Field Values

KEYCODE_MENU

public static final int KEYCODE_MENU
See Also:
Constant Field Values

KEYCODE_NOTIFICATION

public static final int KEYCODE_NOTIFICATION
See Also:
Constant Field Values

KEYCODE_SEARCH

public static final int KEYCODE_SEARCH
See Also:
Constant Field Values

KEYCODE_PLAYPAUSE

public static final int KEYCODE_PLAYPAUSE
See Also:
Constant Field Values

KEYCODE_STOP

public static final int KEYCODE_STOP
See Also:
Constant Field Values

KEYCODE_NEXTSONG

public static final int KEYCODE_NEXTSONG
See Also:
Constant Field Values

KEYCODE_PREVIOUSSONG

public static final int KEYCODE_PREVIOUSSONG
See Also:
Constant Field Values

KEYCODE_REWIND

public static final int KEYCODE_REWIND
See Also:
Constant Field Values

KEYCODE_FORWARD

public static final int KEYCODE_FORWARD
See Also:
Constant Field Values

MAX_KEYCODE

@Deprecated
public static final int MAX_KEYCODE
Deprecated. There are now more than MAX_KEYCODE keycodes. Use getMaxKeyCode() instead.
See Also:
Constant Field Values

ACTION_DOWN

public static final int ACTION_DOWN
getAction() value: the key has been pressed down.

See Also:
Constant Field Values

ACTION_UP

public static final int ACTION_UP
getAction() value: the key has been released.

See Also:
Constant Field Values

ACTION_MULTIPLE

public static final int ACTION_MULTIPLE
getAction() value: multiple duplicate key events have occurred in a row. The {#link getRepeatCount() method returns the number of duplicates.

See Also:
Constant Field Values

META_ALT_ON

public static final int META_ALT_ON

This mask is used to check whether one of the ALT meta keys is pressed.

See Also:
isAltPressed(), getMetaState(), KEYCODE_ALT_LEFT, KEYCODE_ALT_RIGHT, Constant Field Values

META_ALT_LEFT_ON

public static final int META_ALT_LEFT_ON

This mask is used to check whether the left ALT meta key is pressed.

See Also:
isAltPressed(), getMetaState(), KEYCODE_ALT_LEFT, Constant Field Values

META_ALT_RIGHT_ON

public static final int META_ALT_RIGHT_ON

This mask is used to check whether the right the ALT meta key is pressed.

See Also:
isAltPressed(), getMetaState(), KEYCODE_ALT_RIGHT, Constant Field Values

META_SHIFT_ON

public static final int META_SHIFT_ON

This mask is used to check whether one of the SHIFT meta keys is pressed.

See Also:
isShiftPressed(), getMetaState(), KEYCODE_SHIFT_LEFT, KEYCODE_SHIFT_RIGHT, Constant Field Values

META_SHIFT_LEFT_ON

public static final int META_SHIFT_LEFT_ON

This mask is used to check whether the left SHIFT meta key is pressed.

See Also:
isShiftPressed(), getMetaState(), KEYCODE_SHIFT_LEFT, Constant Field Values

META_SHIFT_RIGHT_ON

public static final int META_SHIFT_RIGHT_ON

This mask is used to check whether the right SHIFT meta key is pressed.

See Also:
isShiftPressed(), getMetaState(), KEYCODE_SHIFT_RIGHT, Constant Field Values

META_SYM_ON

public static final int META_SYM_ON

This mask is used to check whether the SYM meta key is pressed.

See Also:
isSymPressed(), getMetaState(), Constant Field Values

FLAG_WOKE_HERE

public static final int FLAG_WOKE_HERE
This mask is set if the device woke because of this key event.

See Also:
Constant Field Values

FLAG_SOFT_KEYBOARD

public static final int FLAG_SOFT_KEYBOARD
This mask is set if the key event was generated by a software keyboard.

See Also:
Constant Field Values

CREATOR

public static final Parcelable.Creator<KeyEvent> CREATOR
Constructor Detail

KeyEvent

public KeyEvent(int action,
                int code)
Create a new key event.

Parameters:
action - Action code: either ACTION_DOWN, ACTION_UP, or ACTION_MULTIPLE.
code - The key code.

KeyEvent

public KeyEvent(long downTime,
                long eventTime,
                int action,
                int code,
                int repeat)
Create a new key event.

Parameters:
downTime - The time (in SystemClock.uptimeMillis()) at which this key code originally went down.
eventTime - The time (in SystemClock.uptimeMillis()) at which this event happened.
action - Action code: either ACTION_DOWN, ACTION_UP, or ACTION_MULTIPLE.
code - The key code.
repeat - A repeat count for down events (> 0 if this is after the initial down) or event count for multiple events.

KeyEvent

public KeyEvent(long downTime,
                long eventTime,
                int action,
                int code,
                int repeat,
                int metaState)
Create a new key event.

Parameters:
downTime - The time (in SystemClock.uptimeMillis()) at which this key code originally went down.
eventTime - The time (in SystemClock.uptimeMillis()) at which this event happened.
action - Action code: either ACTION_DOWN, ACTION_UP, or ACTION_MULTIPLE.
code - The key code.
repeat - A repeat count for down events (> 0 if this is after the initial down) or event count for multiple events.
metaState - Flags indicating which meta keys are currently pressed.

KeyEvent

public KeyEvent(long downTime,
                long eventTime,
                int action,
                int code,
                int repeat,
                int metaState,
                int device,
                int scancode)
Create a new key event.

Parameters:
downTime - The time (in SystemClock.uptimeMillis()) at which this key code originally went down.
eventTime - The time (in SystemClock.uptimeMillis()) at which this event happened.
action - Action code: either ACTION_DOWN, ACTION_UP, or ACTION_MULTIPLE.
code - The key code.
repeat - A repeat count for down events (> 0 if this is after the initial down) or event count for multiple events.
metaState - Flags indicating which meta keys are currently pressed.
device - The device ID that generated the key event.
scancode - Raw device scan code of the event.

KeyEvent

public KeyEvent(long downTime,
                long eventTime,
                int action,
                int code,
                int repeat,
                int metaState,
                int device,
                int scancode,
                int flags)
Create a new key event.

Parameters:
downTime - The time (in SystemClock.uptimeMillis()) at which this key code originally went down.
eventTime - The time (in SystemClock.uptimeMillis()) at which this event happened.
action - Action code: either ACTION_DOWN, ACTION_UP, or ACTION_MULTIPLE.
code - The key code.
repeat - A repeat count for down events (> 0 if this is after the initial down) or event count for multiple events.
metaState - Flags indicating which meta keys are currently pressed.
device - The device ID that generated the key event.
scancode - Raw device scan code of the event.
flags - The flags for this key event

KeyEvent

public KeyEvent(KeyEvent origEvent,
                long eventTime,
                int newRepeat)
Copy an existing key event, modifying its time and repeat count.

Parameters:
origEvent - The existing event to be copied.
eventTime - The new event time (in SystemClock.uptimeMillis()) of the event.
newRepeat - The new repeat count of the event.

KeyEvent

public KeyEvent(KeyEvent origEvent,
                int action)
Copy an existing key event, modifying its action.

Parameters:
origEvent - The existing event to be copied.
action - The new action code of the event.
Method Detail

getMaxKeyCode

public static int getMaxKeyCode()
Returns the maximum keycode.


getDeadChar

public static int getDeadChar(int accent,
                              int c)
Get the character that is produced by putting accent on the character c. For example, getDeadChar('`', 'e') returns è.


isDown

@Deprecated
public final boolean isDown()
Deprecated. 

Don't use in new code, instead explicitly check getAction().

Returns:
If the action is ACTION_DOWN, returns true; else false.

isSystem

public final boolean isSystem()
Is this a system key? System keys can not be used for menu shortcuts. TODO: this information should come from a table somewhere. TODO: should the dpad keys be here? arguably, because they also shouldn't be menu shortcuts


getMetaState

public final int getMetaState()

Returns the state of the meta keys.

Returns:
an integer in which each bit set to 1 represents a pressed meta key
See Also:
isAltPressed(), isShiftPressed(), isSymPressed(), META_ALT_ON, META_SHIFT_ON, META_SYM_ON

getFlags

public final int getFlags()
Returns the flags for this key event.

See Also:
FLAG_WOKE_HERE

isModifierKey

public static boolean isModifierKey(int keyCode)
Returns true if this key code is a modifier key.

Returns:
whether the provided keyCode is one of KEYCODE_SHIFT_LEFT KEYCODE_SHIFT_RIGHT, KEYCODE_ALT_LEFT, KEYCODE_ALT_RIGHT or KEYCODE_SYM.

isAltPressed

public final boolean isAltPressed()

Returns the pressed state of the ALT meta key.

Returns:
true if the ALT key is pressed, false otherwise
See Also:
KEYCODE_ALT_LEFT, KEYCODE_ALT_RIGHT, META_ALT_ON

isShiftPressed

public final boolean isShiftPressed()

Returns the pressed state of the SHIFT meta key.

Returns:
true if the SHIFT key is pressed, false otherwise
See Also:
KEYCODE_SHIFT_LEFT, KEYCODE_SHIFT_RIGHT, META_SHIFT_ON

isSymPressed

public final boolean isSymPressed()

Returns the pressed state of the SYM meta key.

Returns:
true if the SYM key is pressed, false otherwise
See Also:
KEYCODE_SYM, META_SYM_ON

getAction

public final int getAction()
Retrieve the action of this key event. May be either ACTION_DOWN, ACTION_UP, or ACTION_MULTIPLE.

Returns:
The event action: ACTION_DOWN, ACTION_UP, or ACTION_MULTIPLE.

getKeyCode

public final int getKeyCode()
Retrieve the key code of the key event. This is the physical key that was pressed -- not the Unicode character.

Returns:
The key code of the event.

getScanCode

public final int getScanCode()
Retrieve the hardware key id of this key event. These values are not reliable and vary from device to device. Mostly this is here for debugging purposes.


getRepeatCount

public final int getRepeatCount()
Retrieve the repeat count of the event. For both key up and key down events, this is the number of times the key has repeated with the first down starting at 0 and counting up from there. For multiple key events, this is the number of down/up pairs that have occurred.

Returns:
The number of times the key has repeated.

getDownTime

public final long getDownTime()
Retrieve the time of the most recent key down event, in the SystemClock.uptimeMillis() time base. If this is a down event, this will be the same as getEventTime(). Note that when chording keys, this value is the down time of the most recently pressed key, which may not be the same physical key of this event.

Returns:
Returns the most recent key down time, in the SystemClock.uptimeMillis() time base

getEventTime

public final long getEventTime()
Retrieve the time this event occurred, in the SystemClock.uptimeMillis() time base.

Returns:
Returns the time this event occurred, in the SystemClock.uptimeMillis() time base.

getDeviceId

public final int getDeviceId()
Return the id for the keyboard that this event came from. A device id of 0 indicates the event didn't come from a physical device and maps to the default keymap. The other numbers are arbitrary and you shouldn't depend on the values.

See Also:
KeyCharacterMap.load(int)

getKeyboardDevice

public final int getKeyboardDevice()
Deprecated. 

Renamed to getDeviceId().


getDisplayLabel

public char getDisplayLabel()
Get the primary character for this key. In other words, the label that is physically printed on it.


getUnicodeChar

public int getUnicodeChar()

Returns the Unicode character that the key would produce.

Returns 0 if the key is not one that is used to type Unicode characters.

If the return value has bit KeyCharacterMap.COMBINING_ACCENT set, the key is a "dead key" that should be combined with another to actually produce a character -- see getDeadChar(int, int) -- after masking with KeyCharacterMap.COMBINING_ACCENT_MASK.


getUnicodeChar

public int getUnicodeChar(int meta)

Returns the Unicode character that the key would produce.

Returns 0 if the key is not one that is used to type Unicode characters.

If the return value has bit KeyCharacterMap.COMBINING_ACCENT set, the key is a "dead key" that should be combined with another to actually produce a character -- see getDeadChar(int, int) -- after masking with KeyCharacterMap.COMBINING_ACCENT_MASK.


getKeyData

public boolean getKeyData(KeyCharacterMap.KeyData results)
Get the characters conversion data for the key event..

Parameters:
results - a KeyCharacterMap.KeyData that will be filled with the results.
Returns:
whether the key was mapped or not. If the key was not mapped, results is not modified.

getMatch

public char getMatch(char[] chars)
The same as getMatch(chars, 0).


getMatch

public char getMatch(char[] chars,
                     int modifiers)
If one of the chars in the array can be generated by the keyCode of this key event, return the char; otherwise return '\0'.

Parameters:
chars - the characters to try to find
modifiers - the modifier bits to prefer. If any of these bits are set, if there are multiple choices, that could work, the one for this modifier will be set.

getNumber

public char getNumber()
Gets the number or symbol associated with the key. The character value is returned, not the numeric value. If the key is not a number, but is a symbol, the symbol is retuned.


isPrintingKey

public boolean isPrintingKey()
Does the key code of this key produce a glyph?


dispatch

public final boolean dispatch(KeyEvent.Callback receiver)
Deliver this key event to a KeyEvent.Callback interface. If this is an ACTION_MULTIPLE event and it is not handled, then an attempt will be made to deliver a single normal event.

Parameters:
receiver - The Callback that will be given the event.
Returns:
The return value from the Callback method that was called.

toString

public String toString()
Description copied from class: Object
Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation simply concatenates the class name, the '@' sign and a hexadecimal representation of the object's Object.hashCode(), that is, it is equivalent to the following expression:
 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Overrides:
toString in class Object
Returns:
a printable representation of this object.

describeContents

public int describeContents()
Description copied from interface: Parcelable
Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Specified by:
describeContents in interface Parcelable
Returns:
a bitmask indicating the set of special object types marshalled by the Parcelable.

writeToParcel

public void writeToParcel(Parcel out,
                          int flags)
Description copied from interface: Parcelable
Flatten this object in to a Parcel.

Specified by:
writeToParcel in interface Parcelable
Parameters:
out - The Parcel in which the object should be written.
flags - Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.

Build 1.1_r1 (from source)

Please submit a feedback, bug or feature