KeyEvent列表及用法

编写android自动化脚本时,经常会用到KeyEvent(keycode)常量,如:

adb shell input中:
Usage: input [] [...]

The sources are:
      trackball
      joystick
      touchnavigation
      mouse
      keyboard
      gamepad
      touchpad
      dpad
      stylus
      touchscreen

The commands and default sources are:
      text (Default: touchscreen)
      keyevent [--longpress] ... (Default: keyboard)
      tap (Default: touchscreen)
      swipe [duration(ms)] (Default: touchscreen)
      press (Default: trackball)
      roll (Default: trackball)
      tmode

MonkeyRunner中MonkeyDevice的:

void press (string name, integer type)
void type (string message)

uiautomator.UiDevice:

public boolean pressKeyCode (int keyCode)

int ACTION_DOWN getAction() value: the key has been pressed down.
int ACTION_MULTIPLE getAction() value: multiple duplicate key events have occurred in a row, or a complex string is being delivered.
int ACTION_UP getAction() value: the key has been released.
int FLAG_CANCELED When associated with up key events, this indicates that the key press has been canceled.
int FLAG_CANCELED_LONG_PRESS Set when a key event has FLAG_CANCELED set because a long press action was executed while it was down.
int FLAG_EDITOR_ACTION This mask is used for compatibility, to identify enter keys that are coming from an IME whose enter key has been auto-labelled "next" or "done".
int FLAG_FALLBACK Set when a key event has been synthesized to implement default behavior for an event that the application did not handle.
int FLAG_FROM_SYSTEM This mask is set if an event was known to come from a trusted part of the system.
int FLAG_KEEP_TOUCH_MODE This mask is set if we don't want the key event to cause us to leave touch mode.
int FLAG_LONG_PRESS This flag is set for the first key repeat that occurs after the long press timeout.
int FLAG_SOFT_KEYBOARD This mask is set if the key event was generated by a software keyboard.
int FLAG_TRACKING Set for ACTION_UP when this event's key code is still being tracked from its initial down.
int FLAG_VIRTUAL_HARD_KEY This key event was generated by a virtual (on-screen) hard key area.
int FLAG_WOKE_HERE This constant was deprecated in API level 20. This flag will never be set by the system since the system consumes all wake keys itself.
int KEYCODE_0 Key code constant: '0' key.
int KEYCODE_1 Key code constant: '1' key.
int KEYCODE_11 Key code constant: '11' key.
int KEYCODE_12 Key code constant: '12' key.
int KEYCODE_2 Key code constant: '2' key.
int KEYCODE_3 Key code constant: '3' key.
int KEYCODE_3D_MODE Key code constant: 3D Mode key.
int KEYCODE_4 Key code constant: '4' key.
int KEYCODE_5 Key code constant: '5' key.
int KEYCODE_6 Key code constant: '6' key.
int KEYCODE_7 Key code constant: '7' key.
int KEYCODE_8 Key code constant: '8' key.
int KEYCODE_9 Key code constant: '9' key.
int KEYCODE_A Key code constant: 'A' key.
int KEYCODE_ALT_LEFT Key code constant: Left Alt modifier key.
int KEYCODE_ALT_RIGHT Key code constant: Right Alt modifier key.
int KEYCODE_APOSTROPHE Key code constant: ''' (apostrophe) key.
int KEYCODE_APP_SWITCH Key code constant: App switch key.
int KEYCODE_ASSIST Key code constant: Assist key.
int KEYCODE_AT Key code constant: '@' key.
int KEYCODE_AVR_INPUT Key code constant: A/V Receiver input key.
int KEYCODE_AVR_POWER Key code constant: A/V Receiver power key.
int KEYCODE_B Key code constant: 'B' key.
int KEYCODE_BACK Key code constant: Back key.
int KEYCODE_BACKSLASH Key code constant: '\' key.
int KEYCODE_BOOKMARK Key code constant: Bookmark key.
int KEYCODE_BREAK Key code constant: Break / Pause key.
int KEYCODE_BRIGHTNESS_DOWN Key code constant: Brightness Down key.
int KEYCODE_BRIGHTNESS_UP Key code constant: Brightness Up key.
int KEYCODE_BUTTON_1 Key code constant: Generic Game Pad Button #1.
int KEYCODE_BUTTON_10 Key code constant: Generic Game Pad Button #10.
int KEYCODE_BUTTON_11 Key code constant: Generic Game Pad Button #11.
int KEYCODE_BUTTON_12 Key code constant: Generic Game Pad Button #12.
int KEYCODE_BUTTON_13 Key code constant: Generic Game Pad Button #13.
int KEYCODE_BUTTON_14 Key code constant: Generic Game Pad Button #14.
int KEYCODE_BUTTON_15 Key code constant: Generic Game Pad Button #15.
int KEYCODE_BUTTON_16 Key code constant: Generic Game Pad Button #16.
int KEYCODE_BUTTON_2 Key code constant: Generic Game Pad Button #2.
int KEYCODE_BUTTON_3 Key code constant: Generic Game Pad Button #3.
int KEYCODE_BUTTON_4 Key code constant: Generic Game Pad Button #4.
int KEYCODE_BUTTON_5 Key code constant: Generic Game Pad Button #5.
int KEYCODE_BUTTON_6 Key code constant: Generic Game Pad Button #6.
int KEYCODE_BUTTON_7 Key code constant: Generic Game Pad Button #7.
int KEYCODE_BUTTON_8 Key code constant: Generic Game Pad Button #8.
int KEYCODE_BUTTON_9 Key code constant: Generic Game Pad Button #9.
int KEYCODE_BUTTON_A Key code constant: A Button key.
int KEYCODE_BUTTON_B Key code constant: B Button key.
int KEYCODE_BUTTON_C Key code constant: C Button key.
int KEYCODE_BUTTON_L1 Key code constant: L1 Button key.
int KEYCODE_BUTTON_L2 Key code constant: L2 Button key.
int KEYCODE_BUTTON_MODE Key code constant: Mode Button key.
int KEYCODE_BUTTON_R1 Key code constant: R1 Button key.
int KEYCODE_BUTTON_R2 Key code constant: R2 Button key.
int KEYCODE_BUTTON_SELECT Key code constant: Select Button key.
int KEYCODE_BUTTON_START Key code constant: Start Button key.
int KEYCODE_BUTTON_THUMBL Key code constant: Left Thumb Button key.
int KEYCODE_BUTTON_THUMBR Key code constant: Right Thumb Button key.
int KEYCODE_BUTTON_X Key code constant: X Button key.
int KEYCODE_BUTTON_Y Key code constant: Y Button key.
int KEYCODE_BUTTON_Z Key code constant: Z Button key.
int KEYCODE_C Key code constant: 'C' key.
int KEYCODE_CALCULATOR Key code constant: Calculator special function key.
int KEYCODE_CALENDAR Key code constant: Calendar special function key.
int KEYCODE_CALL Key code constant: Call key.
int KEYCODE_CAMERA Key code constant: Camera key.
int KEYCODE_CAPS_LOCK Key code constant: Caps Lock key.
int KEYCODE_CAPTIONS Key code constant: Toggle captions key.
int KEYCODE_CHANNEL_DOWN Key code constant: Channel down key.
int KEYCODE_CHANNEL_UP Key code constant: Channel up key.
int KEYCODE_CLEAR Key code constant: Clear key.
int KEYCODE_COMMA Key code constant: ',' key.
int KEYCODE_CONTACTS Key code constant: Contacts special function key.
int KEYCODE_CTRL_LEFT Key code constant: Left Control modifier key.
int KEYCODE_CTRL_RIGHT Key code constant: Right Control modifier key.
int KEYCODE_D Key code constant: 'D' key.
int KEYCODE_DEL Key code constant: Backspace key.
int KEYCODE_DPAD_CENTER Key code constant: Directional Pad Center key.
int KEYCODE_DPAD_DOWN Key code constant: Directional Pad Down key.
int KEYCODE_DPAD_LEFT Key code constant: Directional Pad Left key.
int KEYCODE_DPAD_RIGHT Key code constant: Directional Pad Right key.
int KEYCODE_DPAD_UP Key code constant: Directional Pad Up key.
int KEYCODE_DVR Key code constant: DVR key.
int KEYCODE_E Key code constant: 'E' key.
int KEYCODE_EISU Key code constant: Japanese alphanumeric key.
int KEYCODE_ENDCALL Key code constant: End Call key.
int KEYCODE_ENTER Key code constant: Enter key.
int KEYCODE_ENVELOPE Key code constant: Envelope special function key.
int KEYCODE_EQUALS Key code constant: '=' key.
int KEYCODE_ESCAPE Key code constant: Escape key.
int KEYCODE_EXPLORER Key code constant: Explorer special function key.
int KEYCODE_F Key code constant: 'F' key.
int KEYCODE_F1 Key code constant: F1 key.
int KEYCODE_F10 Key code constant: F10 key.
int KEYCODE_F11 Key code constant: F11 key.
int KEYCODE_F12 Key code constant: F12 key.
int KEYCODE_F2 Key code constant: F2 key.
int KEYCODE_F3 Key code constant: F3 key.
int KEYCODE_F4 Key code constant: F4 key.
int KEYCODE_F5 Key code constant: F5 key.
int KEYCODE_F6 Key code constant: F6 key.
int KEYCODE_F7 Key code constant: F7 key.
int KEYCODE_F8 Key code constant: F8 key.
int KEYCODE_F9 Key code constant: F9 key.
int KEYCODE_FOCUS Key code constant: Camera Focus key.
int KEYCODE_FORWARD Key code constant: Forward key.
int KEYCODE_FORWARD_DEL Key code constant: Forward Delete key.
int KEYCODE_FUNCTION Key code constant: Function modifier key.
int KEYCODE_G Key code constant: 'G' key.
int KEYCODE_GRAVE Key code constant: '`' (backtick) key.
int KEYCODE_GUIDE Key code constant: Guide key.
int KEYCODE_H Key code constant: 'H' key.
int KEYCODE_HEADSETHOOK Key code constant: Headset Hook key.
int KEYCODE_HELP Key code constant: Help key.
int KEYCODE_HENKAN Key code constant: Japanese conversion key.
int KEYCODE_HOME Key code constant: Home key.
int KEYCODE_I Key code constant: 'I' key.
int KEYCODE_INFO Key code constant: Info key.
int KEYCODE_INSERT Key code constant: Insert key.
int KEYCODE_J Key code constant: 'J' key.
int KEYCODE_K Key code constant: 'K' key.
int KEYCODE_KANA Key code constant: Japanese kana key.
int KEYCODE_KATAKANA_HIRAGANA Key code constant: Japanese katakana / hiragana key.
int KEYCODE_L Key code constant: 'L' key.
int KEYCODE_LANGUAGE_SWITCH Key code constant: Language Switch key.
int KEYCODE_LAST_CHANNEL Key code constant: Last Channel key.
int KEYCODE_LEFT_BRACKET Key code constant: '[' key.
int KEYCODE_M Key code constant: 'M' key.
int KEYCODE_MANNER_MODE Key code constant: Manner Mode key.
int KEYCODE_MEDIA_AUDIO_TRACK Key code constant: Audio Track key.
int KEYCODE_MEDIA_CLOSE Key code constant: Close media key.
int KEYCODE_MEDIA_EJECT Key code constant: Eject media key.
int KEYCODE_MEDIA_FAST_FORWARD Key code constant: Fast Forward media key.
int KEYCODE_MEDIA_NEXT Key code constant: Play Next media key.
int KEYCODE_MEDIA_PAUSE Key code constant: Pause media key.
int KEYCODE_MEDIA_PLAY Key code constant: Play media key.
int KEYCODE_MEDIA_PLAY_PAUSE Key code constant: Play/Pause media key.
int KEYCODE_MEDIA_PREVIOUS Key code constant: Play Previous media key.
int KEYCODE_MEDIA_RECORD Key code constant: Record media key.
int KEYCODE_MEDIA_REWIND Key code constant: Rewind media key.
int KEYCODE_MEDIA_SKIP_BACKWARD Key code constant: Skip backward media key.
int KEYCODE_MEDIA_SKIP_FORWARD Key code constant: Skip forward media key.
int KEYCODE_MEDIA_STEP_BACKWARD Key code constant: Step backward media key.
int KEYCODE_MEDIA_STEP_FORWARD Key code constant: Step forward media key.
int KEYCODE_MEDIA_STOP Key code constant: Stop media key.
int KEYCODE_MEDIA_TOP_MENU Key code constant: Media Top Menu key.
int KEYCODE_MENU Key code constant: Menu key.
int KEYCODE_META_LEFT Key code constant: Left Meta modifier key.
int KEYCODE_META_RIGHT Key code constant: Right Meta modifier key.
int KEYCODE_MINUS Key code constant: '-'.
int KEYCODE_MOVE_END Key code constant: End Movement key.
int KEYCODE_MOVE_HOME Key code constant: Home Movement key.
int KEYCODE_MUHENKAN Key code constant: Japanese non-conversion key.
int KEYCODE_MUSIC Key code constant: Music special function key.
int KEYCODE_MUTE Key code constant: Mute key.
int KEYCODE_N Key code constant: 'N' key.
int KEYCODE_NAVIGATE_IN Key code constant: Navigate in key.
int KEYCODE_NAVIGATE_NEXT Key code constant: Navigate to next key.
int KEYCODE_NAVIGATE_OUT Key code constant: Navigate out key.
int KEYCODE_NAVIGATE_PREVIOUS Key code constant: Navigate to previous key.
int KEYCODE_NOTIFICATION Key code constant: Notification key.
int KEYCODE_NUM Key code constant: Number modifier key.
int KEYCODE_NUMPAD_0 Key code constant: Numeric keypad '0' key.
int KEYCODE_NUMPAD_1 Key code constant: Numeric keypad '1' key.
int KEYCODE_NUMPAD_2 Key code constant: Numeric keypad '2' key.
int KEYCODE_NUMPAD_3 Key code constant: Numeric keypad '3' key.
int KEYCODE_NUMPAD_4 Key code constant: Numeric keypad '4' key.
int KEYCODE_NUMPAD_5 Key code constant: Numeric keypad '5' key.
int KEYCODE_NUMPAD_6 Key code constant: Numeric keypad '6' key.
int KEYCODE_NUMPAD_7 Key code constant: Numeric keypad '7' key.
int KEYCODE_NUMPAD_8 Key code constant: Numeric keypad '8' key.
int KEYCODE_NUMPAD_9 Key code constant: Numeric keypad '9' key.
int KEYCODE_NUMPAD_ADD Key code constant: Numeric keypad '+' key (for addition).
int KEYCODE_NUMPAD_COMMA Key code constant: Numeric keypad ',' key (for decimals or digit grouping).
int KEYCODE_NUMPAD_DIVIDE Key code constant: Numeric keypad '/' key (for division).
int KEYCODE_NUMPAD_DOT Key code constant: Numeric keypad '.' key (for decimals or digit grouping).
int KEYCODE_NUMPAD_ENTER Key code constant: Numeric keypad Enter key.
int KEYCODE_NUMPAD_EQUALS Key code constant: Numeric keypad '=' key.
int KEYCODE_NUMPAD_LEFT_PAREN Key code constant: Numeric keypad '(' key.
int KEYCODE_NUMPAD_MULTIPLY Key code constant: Numeric keypad '*' key (for multiplication).
int KEYCODE_NUMPAD_RIGHT_PAREN Key code constant: Numeric keypad ')' key.
int KEYCODE_NUMPAD_SUBTRACT Key code constant: Numeric keypad '-' key (for subtraction).
int KEYCODE_NUM_LOCK Key code constant: Num Lock key.
int KEYCODE_O Key code constant: 'O' key.
int KEYCODE_P Key code constant: 'P' key.
int KEYCODE_PAGE_DOWN Key code constant: Page Down key.
int KEYCODE_PAGE_UP Key code constant: Page Up key.
int KEYCODE_PAIRING Key code constant: Pairing key.
int KEYCODE_PERIOD Key code constant: '.' key.
int KEYCODE_PICTSYMBOLS Key code constant: Picture Symbols modifier key.
int KEYCODE_PLUS Key code constant: '+' key.
int KEYCODE_POUND Key code constant: '#' key.
int KEYCODE_POWER Key code constant: Power key.
int KEYCODE_PROG_BLUE Key code constant: Blue "programmable" key.
int KEYCODE_PROG_GREEN Key code constant: Green "programmable" key.
int KEYCODE_PROG_RED Key code constant: Red "programmable" key.
int KEYCODE_PROG_YELLOW Key code constant: Yellow "programmable" key.
int KEYCODE_Q Key code constant: 'Q' key.
int KEYCODE_R Key code constant: 'R' key.
int KEYCODE_RIGHT_BRACKET Key code constant: ']' key.
int KEYCODE_RO Key code constant: Japanese Ro key.
int KEYCODE_S Key code constant: 'S' key.
int KEYCODE_SCROLL_LOCK Key code constant: Scroll Lock key.
int KEYCODE_SEARCH Key code constant: Search key.
int KEYCODE_SEMICOLON Key code constant: ';' key.
int KEYCODE_SETTINGS Key code constant: Settings key.
int KEYCODE_SHIFT_LEFT Key code constant: Left Shift modifier key.
int KEYCODE_SHIFT_RIGHT Key code constant: Right Shift modifier key.
int KEYCODE_SLASH Key code constant: '/' key.
int KEYCODE_SLEEP Key code constant: Sleep key.
int KEYCODE_SOFT_LEFT Key code constant: Soft Left key.
int KEYCODE_SOFT_RIGHT Key code constant: Soft Right key.
int KEYCODE_SPACE Key code constant: Space key.
int KEYCODE_STAR Key code constant: '*' key.
int KEYCODE_STB_INPUT Key code constant: Set-top-box input key.
int KEYCODE_STB_POWER Key code constant: Set-top-box power key.
int KEYCODE_SWITCH_CHARSET Key code constant: Switch Charset modifier key.
int KEYCODE_SYM Key code constant: Symbol modifier key.
int KEYCODE_SYSRQ Key code constant: System Request / Print Screen key.
int KEYCODE_T Key code constant: 'T' key.
int KEYCODE_TAB Key code constant: Tab key.
int KEYCODE_TV Key code constant: TV key.
int KEYCODE_TV_ANTENNA_CABLE Key code constant: Antenna/Cable key.
int KEYCODE_TV_AUDIO_DESCRIPTION Key code constant: Audio description key.
int KEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN Key code constant: Audio description mixing volume down key.
int KEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP Key code constant: Audio description mixing volume up key.
int KEYCODE_TV_CONTENTS_MENU Key code constant: Contents menu key.
int KEYCODE_TV_DATA_SERVICE Key code constant: TV data service key.
int KEYCODE_TV_INPUT Key code constant: TV input key.
int KEYCODE_TV_INPUT_COMPONENT_1 Key code constant: Component #1 key.
int KEYCODE_TV_INPUT_COMPONENT_2 Key code constant: Component #2 key.
int KEYCODE_TV_INPUT_COMPOSITE_1 Key code constant: Composite #1 key.
int KEYCODE_TV_INPUT_COMPOSITE_2 Key code constant: Composite #2 key.
int KEYCODE_TV_INPUT_HDMI_1 Key code constant: HDMI #1 key.
int KEYCODE_TV_INPUT_HDMI_2 Key code constant: HDMI #2 key.
int KEYCODE_TV_INPUT_HDMI_3 Key code constant: HDMI #3 key.
int KEYCODE_TV_INPUT_HDMI_4 Key code constant: HDMI #4 key.
int KEYCODE_TV_INPUT_VGA_1 Key code constant: VGA #1 key.
int KEYCODE_TV_MEDIA_CONTEXT_MENU Key code constant: Media context menu key.
int KEYCODE_TV_NETWORK Key code constant: Toggle Network key.
int KEYCODE_TV_NUMBER_ENTRY Key code constant: Number entry key.
int KEYCODE_TV_POWER Key code constant: TV power key.
int KEYCODE_TV_RADIO_SERVICE Key code constant: Radio key.
int KEYCODE_TV_SATELLITE Key code constant: Satellite key.
int KEYCODE_TV_SATELLITE_BS Key code constant: BS key.
int KEYCODE_TV_SATELLITE_CS Key code constant: CS key.
int KEYCODE_TV_SATELLITE_SERVICE Key code constant: BS/CS key.
int KEYCODE_TV_TELETEXT Key code constant: Teletext key.
int KEYCODE_TV_TERRESTRIAL_ANALOG Key code constant: Analog Terrestrial key.
int KEYCODE_TV_TERRESTRIAL_DIGITAL Key code constant: Digital Terrestrial key.
int KEYCODE_TV_TIMER_PROGRAMMING Key code constant: Timer programming key.
int KEYCODE_TV_ZOOM_MODE Key code constant: Zoom mode key.
int KEYCODE_U Key code constant: 'U' key.
int KEYCODE_UNKNOWN Key code constant: Unknown key code.
int KEYCODE_V Key code constant: 'V' key.
int KEYCODE_VOICE_ASSIST Key code constant: Voice Assist key.
int KEYCODE_VOLUME_DOWN Key code constant: Volume Down key.
int KEYCODE_VOLUME_MUTE Key code constant: Volume Mute key.
int KEYCODE_VOLUME_UP Key code constant: Volume Up key.
int KEYCODE_W Key code constant: 'W' key.
int KEYCODE_WAKEUP Key code constant: Wakeup key.
int KEYCODE_WINDOW Key code constant: Window key.
int KEYCODE_X Key code constant: 'X' key.
int KEYCODE_Y Key code constant: 'Y' key.
int KEYCODE_YEN Key code constant: Japanese Yen key.
int KEYCODE_Z Key code constant: 'Z' key.
int KEYCODE_ZENKAKU_HANKAKU Key code constant: Japanese full-width / half-width key.
int KEYCODE_ZOOM_IN Key code constant: Zoom in key.
int KEYCODE_ZOOM_OUT Key code constant: Zoom out key.
int MAX_KEYCODE This constant was deprecated in API level 3. There are now more than MAX_KEYCODE keycodes. Use getMaxKeyCode() instead.
int META_ALT_LEFT_ON

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

int META_ALT_MASK This mask is a combination of META_ALT_ON, META_ALT_LEFT_ON and META_ALT_RIGHT_ON.
int META_ALT_ON

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

int META_ALT_RIGHT_ON

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

int META_CAPS_LOCK_ON

This mask is used to check whether the CAPS LOCK meta key is on.

int META_CTRL_LEFT_ON

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

int META_CTRL_MASK This mask is a combination of META_CTRL_ON, META_CTRL_LEFT_ON and META_CTRL_RIGHT_ON.
int META_CTRL_ON

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

int META_CTRL_RIGHT_ON

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

int META_FUNCTION_ON

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

int META_META_LEFT_ON

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

int META_META_MASK This mask is a combination of META_META_ON, META_META_LEFT_ON and META_META_RIGHT_ON.
int META_META_ON

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

int META_META_RIGHT_ON

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

int META_NUM_LOCK_ON

This mask is used to check whether the NUM LOCK meta key is on.

int META_SCROLL_LOCK_ON

This mask is used to check whether the SCROLL LOCK meta key is on.

int META_SHIFT_LEFT_ON

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

int META_SHIFT_MASK This mask is a combination of META_SHIFT_ON, META_SHIFT_LEFT_ON and META_SHIFT_RIGHT_ON.
int META_SHIFT_ON

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

int META_SHIFT_RIGHT_ON

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

int META_SYM_ON

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


是扥


你可能感兴趣的:(KeyEvent列表及用法)