KeyEvent列表及用法

来源:互联网 发布:m9军刀多少钱淘宝 编辑:程序博客网 时间:2024/05/22 07:03

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

adb shell input中:
Usage: input [<source>] <command> [<arg>...]

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

The commands and default sources are:
      text <string> (Default: touchscreen)
      keyevent [--longpress] <key code number or name> ... (Default: keyboard)
      tap <x> <y> (Default: touchscreen)
      swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)
      press (Default: trackball)
      roll <dx> <dy> (Default: trackball)
      tmode <tmode>

MonkeyRunner中MonkeyDevice的:

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

uiautomator.UiDevice:

public boolean pressKeyCode (int keyCode)

intACTION_DOWNgetAction() value: the key has been pressed down.intACTION_MULTIPLEgetAction() value: multiple duplicate key events have occurred in a row, or a complex string is being delivered.intACTION_UPgetAction() value: the key has been released.intFLAG_CANCELEDWhen associated with up key events, this indicates that the key press has been canceled.intFLAG_CANCELED_LONG_PRESSSet when a key event has FLAG_CANCELED set because a long press action was executed while it was down.intFLAG_EDITOR_ACTIONThis 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".intFLAG_FALLBACKSet when a key event has been synthesized to implement default behavior for an event that the application did not handle.intFLAG_FROM_SYSTEMThis mask is set if an event was known to come from a trusted part of the system.intFLAG_KEEP_TOUCH_MODEThis mask is set if we don't want the key event to cause us to leave touch mode.intFLAG_LONG_PRESSThis flag is set for the first key repeat that occurs after the long press timeout.intFLAG_SOFT_KEYBOARDThis mask is set if the key event was generated by a software keyboard.intFLAG_TRACKINGSet for ACTION_UP when this event's key code is still being tracked from its initial down.intFLAG_VIRTUAL_HARD_KEYThis key event was generated by a virtual (on-screen) hard key area.intFLAG_WOKE_HEREThis constant was deprecated in API level 20. This flag will never be set by the system since the system consumes all wake keys itself.intKEYCODE_0Key code constant: '0' key.intKEYCODE_1Key code constant: '1' key.intKEYCODE_11Key code constant: '11' key.intKEYCODE_12Key code constant: '12' key.intKEYCODE_2Key code constant: '2' key.intKEYCODE_3Key code constant: '3' key.intKEYCODE_3D_MODEKey code constant: 3D Mode key.intKEYCODE_4Key code constant: '4' key.intKEYCODE_5Key code constant: '5' key.intKEYCODE_6Key code constant: '6' key.intKEYCODE_7Key code constant: '7' key.intKEYCODE_8Key code constant: '8' key.intKEYCODE_9Key code constant: '9' key.intKEYCODE_AKey code constant: 'A' key.intKEYCODE_ALT_LEFTKey code constant: Left Alt modifier key.intKEYCODE_ALT_RIGHTKey code constant: Right Alt modifier key.intKEYCODE_APOSTROPHEKey code constant: ''' (apostrophe) key.intKEYCODE_APP_SWITCHKey code constant: App switch key.intKEYCODE_ASSISTKey code constant: Assist key.intKEYCODE_ATKey code constant: '@' key.intKEYCODE_AVR_INPUTKey code constant: A/V Receiver input key.intKEYCODE_AVR_POWERKey code constant: A/V Receiver power key.intKEYCODE_BKey code constant: 'B' key.intKEYCODE_BACKKey code constant: Back key.intKEYCODE_BACKSLASHKey code constant: '\' key.intKEYCODE_BOOKMARKKey code constant: Bookmark key.intKEYCODE_BREAKKey code constant: Break / Pause key.intKEYCODE_BRIGHTNESS_DOWNKey code constant: Brightness Down key.intKEYCODE_BRIGHTNESS_UPKey code constant: Brightness Up key.intKEYCODE_BUTTON_1Key code constant: Generic Game Pad Button #1.intKEYCODE_BUTTON_10Key code constant: Generic Game Pad Button #10.intKEYCODE_BUTTON_11Key code constant: Generic Game Pad Button #11.intKEYCODE_BUTTON_12Key code constant: Generic Game Pad Button #12.intKEYCODE_BUTTON_13Key code constant: Generic Game Pad Button #13.intKEYCODE_BUTTON_14Key code constant: Generic Game Pad Button #14.intKEYCODE_BUTTON_15Key code constant: Generic Game Pad Button #15.intKEYCODE_BUTTON_16Key code constant: Generic Game Pad Button #16.intKEYCODE_BUTTON_2Key code constant: Generic Game Pad Button #2.intKEYCODE_BUTTON_3Key code constant: Generic Game Pad Button #3.intKEYCODE_BUTTON_4Key code constant: Generic Game Pad Button #4.intKEYCODE_BUTTON_5Key code constant: Generic Game Pad Button #5.intKEYCODE_BUTTON_6Key code constant: Generic Game Pad Button #6.intKEYCODE_BUTTON_7Key code constant: Generic Game Pad Button #7.intKEYCODE_BUTTON_8Key code constant: Generic Game Pad Button #8.intKEYCODE_BUTTON_9Key code constant: Generic Game Pad Button #9.intKEYCODE_BUTTON_AKey code constant: A Button key.intKEYCODE_BUTTON_BKey code constant: B Button key.intKEYCODE_BUTTON_CKey code constant: C Button key.intKEYCODE_BUTTON_L1Key code constant: L1 Button key.intKEYCODE_BUTTON_L2Key code constant: L2 Button key.intKEYCODE_BUTTON_MODEKey code constant: Mode Button key.intKEYCODE_BUTTON_R1Key code constant: R1 Button key.intKEYCODE_BUTTON_R2Key code constant: R2 Button key.intKEYCODE_BUTTON_SELECTKey code constant: Select Button key.intKEYCODE_BUTTON_STARTKey code constant: Start Button key.intKEYCODE_BUTTON_THUMBLKey code constant: Left Thumb Button key.intKEYCODE_BUTTON_THUMBRKey code constant: Right Thumb Button key.intKEYCODE_BUTTON_XKey code constant: X Button key.intKEYCODE_BUTTON_YKey code constant: Y Button key.intKEYCODE_BUTTON_ZKey code constant: Z Button key.intKEYCODE_CKey code constant: 'C' key.intKEYCODE_CALCULATORKey code constant: Calculator special function key.intKEYCODE_CALENDARKey code constant: Calendar special function key.intKEYCODE_CALLKey code constant: Call key.intKEYCODE_CAMERAKey code constant: Camera key.intKEYCODE_CAPS_LOCKKey code constant: Caps Lock key.intKEYCODE_CAPTIONSKey code constant: Toggle captions key.intKEYCODE_CHANNEL_DOWNKey code constant: Channel down key.intKEYCODE_CHANNEL_UPKey code constant: Channel up key.intKEYCODE_CLEARKey code constant: Clear key.intKEYCODE_COMMAKey code constant: ',' key.intKEYCODE_CONTACTSKey code constant: Contacts special function key.intKEYCODE_CTRL_LEFTKey code constant: Left Control modifier key.intKEYCODE_CTRL_RIGHTKey code constant: Right Control modifier key.intKEYCODE_DKey code constant: 'D' key.intKEYCODE_DELKey code constant: Backspace key.intKEYCODE_DPAD_CENTERKey code constant: Directional Pad Center key.intKEYCODE_DPAD_DOWNKey code constant: Directional Pad Down key.intKEYCODE_DPAD_LEFTKey code constant: Directional Pad Left key.intKEYCODE_DPAD_RIGHTKey code constant: Directional Pad Right key.intKEYCODE_DPAD_UPKey code constant: Directional Pad Up key.intKEYCODE_DVRKey code constant: DVR key.intKEYCODE_EKey code constant: 'E' key.intKEYCODE_EISUKey code constant: Japanese alphanumeric key.intKEYCODE_ENDCALLKey code constant: End Call key.intKEYCODE_ENTERKey code constant: Enter key.intKEYCODE_ENVELOPEKey code constant: Envelope special function key.intKEYCODE_EQUALSKey code constant: '=' key.intKEYCODE_ESCAPEKey code constant: Escape key.intKEYCODE_EXPLORERKey code constant: Explorer special function key.intKEYCODE_FKey code constant: 'F' key.intKEYCODE_F1Key code constant: F1 key.intKEYCODE_F10Key code constant: F10 key.intKEYCODE_F11Key code constant: F11 key.intKEYCODE_F12Key code constant: F12 key.intKEYCODE_F2Key code constant: F2 key.intKEYCODE_F3Key code constant: F3 key.intKEYCODE_F4Key code constant: F4 key.intKEYCODE_F5Key code constant: F5 key.intKEYCODE_F6Key code constant: F6 key.intKEYCODE_F7Key code constant: F7 key.intKEYCODE_F8Key code constant: F8 key.intKEYCODE_F9Key code constant: F9 key.intKEYCODE_FOCUSKey code constant: Camera Focus key.intKEYCODE_FORWARDKey code constant: Forward key.intKEYCODE_FORWARD_DELKey code constant: Forward Delete key.intKEYCODE_FUNCTIONKey code constant: Function modifier key.intKEYCODE_GKey code constant: 'G' key.intKEYCODE_GRAVEKey code constant: '`' (backtick) key.intKEYCODE_GUIDEKey code constant: Guide key.intKEYCODE_HKey code constant: 'H' key.intKEYCODE_HEADSETHOOKKey code constant: Headset Hook key.intKEYCODE_HELPKey code constant: Help key.intKEYCODE_HENKANKey code constant: Japanese conversion key.intKEYCODE_HOMEKey code constant: Home key.intKEYCODE_IKey code constant: 'I' key.intKEYCODE_INFOKey code constant: Info key.intKEYCODE_INSERTKey code constant: Insert key.intKEYCODE_JKey code constant: 'J' key.intKEYCODE_KKey code constant: 'K' key.intKEYCODE_KANAKey code constant: Japanese kana key.intKEYCODE_KATAKANA_HIRAGANAKey code constant: Japanese katakana / hiragana key.intKEYCODE_LKey code constant: 'L' key.intKEYCODE_LANGUAGE_SWITCHKey code constant: Language Switch key.intKEYCODE_LAST_CHANNELKey code constant: Last Channel key.intKEYCODE_LEFT_BRACKETKey code constant: '[' key.intKEYCODE_MKey code constant: 'M' key.intKEYCODE_MANNER_MODEKey code constant: Manner Mode key.intKEYCODE_MEDIA_AUDIO_TRACKKey code constant: Audio Track key.intKEYCODE_MEDIA_CLOSEKey code constant: Close media key.intKEYCODE_MEDIA_EJECTKey code constant: Eject media key.intKEYCODE_MEDIA_FAST_FORWARDKey code constant: Fast Forward media key.intKEYCODE_MEDIA_NEXTKey code constant: Play Next media key.intKEYCODE_MEDIA_PAUSEKey code constant: Pause media key.intKEYCODE_MEDIA_PLAYKey code constant: Play media key.intKEYCODE_MEDIA_PLAY_PAUSEKey code constant: Play/Pause media key.intKEYCODE_MEDIA_PREVIOUSKey code constant: Play Previous media key.intKEYCODE_MEDIA_RECORDKey code constant: Record media key.intKEYCODE_MEDIA_REWINDKey code constant: Rewind media key.intKEYCODE_MEDIA_SKIP_BACKWARDKey code constant: Skip backward media key.intKEYCODE_MEDIA_SKIP_FORWARDKey code constant: Skip forward media key.intKEYCODE_MEDIA_STEP_BACKWARDKey code constant: Step backward media key.intKEYCODE_MEDIA_STEP_FORWARDKey code constant: Step forward media key.intKEYCODE_MEDIA_STOPKey code constant: Stop media key.intKEYCODE_MEDIA_TOP_MENUKey code constant: Media Top Menu key.intKEYCODE_MENUKey code constant: Menu key.intKEYCODE_META_LEFTKey code constant: Left Meta modifier key.intKEYCODE_META_RIGHTKey code constant: Right Meta modifier key.intKEYCODE_MINUSKey code constant: '-'.intKEYCODE_MOVE_ENDKey code constant: End Movement key.intKEYCODE_MOVE_HOMEKey code constant: Home Movement key.intKEYCODE_MUHENKANKey code constant: Japanese non-conversion key.intKEYCODE_MUSICKey code constant: Music special function key.intKEYCODE_MUTEKey code constant: Mute key.intKEYCODE_NKey code constant: 'N' key.intKEYCODE_NAVIGATE_INKey code constant: Navigate in key.intKEYCODE_NAVIGATE_NEXTKey code constant: Navigate to next key.intKEYCODE_NAVIGATE_OUTKey code constant: Navigate out key.intKEYCODE_NAVIGATE_PREVIOUSKey code constant: Navigate to previous key.intKEYCODE_NOTIFICATIONKey code constant: Notification key.intKEYCODE_NUMKey code constant: Number modifier key.intKEYCODE_NUMPAD_0Key code constant: Numeric keypad '0' key.intKEYCODE_NUMPAD_1Key code constant: Numeric keypad '1' key.intKEYCODE_NUMPAD_2Key code constant: Numeric keypad '2' key.intKEYCODE_NUMPAD_3Key code constant: Numeric keypad '3' key.intKEYCODE_NUMPAD_4Key code constant: Numeric keypad '4' key.intKEYCODE_NUMPAD_5Key code constant: Numeric keypad '5' key.intKEYCODE_NUMPAD_6Key code constant: Numeric keypad '6' key.intKEYCODE_NUMPAD_7Key code constant: Numeric keypad '7' key.intKEYCODE_NUMPAD_8Key code constant: Numeric keypad '8' key.intKEYCODE_NUMPAD_9Key code constant: Numeric keypad '9' key.intKEYCODE_NUMPAD_ADDKey code constant: Numeric keypad '+' key (for addition).intKEYCODE_NUMPAD_COMMAKey code constant: Numeric keypad ',' key (for decimals or digit grouping).intKEYCODE_NUMPAD_DIVIDEKey code constant: Numeric keypad '/' key (for division).intKEYCODE_NUMPAD_DOTKey code constant: Numeric keypad '.' key (for decimals or digit grouping).intKEYCODE_NUMPAD_ENTERKey code constant: Numeric keypad Enter key.intKEYCODE_NUMPAD_EQUALSKey code constant: Numeric keypad '=' key.intKEYCODE_NUMPAD_LEFT_PARENKey code constant: Numeric keypad '(' key.intKEYCODE_NUMPAD_MULTIPLYKey code constant: Numeric keypad '*' key (for multiplication).intKEYCODE_NUMPAD_RIGHT_PARENKey code constant: Numeric keypad ')' key.intKEYCODE_NUMPAD_SUBTRACTKey code constant: Numeric keypad '-' key (for subtraction).intKEYCODE_NUM_LOCKKey code constant: Num Lock key.intKEYCODE_OKey code constant: 'O' key.intKEYCODE_PKey code constant: 'P' key.intKEYCODE_PAGE_DOWNKey code constant: Page Down key.intKEYCODE_PAGE_UPKey code constant: Page Up key.intKEYCODE_PAIRINGKey code constant: Pairing key.intKEYCODE_PERIODKey code constant: '.' key.intKEYCODE_PICTSYMBOLSKey code constant: Picture Symbols modifier key.intKEYCODE_PLUSKey code constant: '+' key.intKEYCODE_POUNDKey code constant: '#' key.intKEYCODE_POWERKey code constant: Power key.intKEYCODE_PROG_BLUEKey code constant: Blue "programmable" key.intKEYCODE_PROG_GREENKey code constant: Green "programmable" key.intKEYCODE_PROG_REDKey code constant: Red "programmable" key.intKEYCODE_PROG_YELLOWKey code constant: Yellow "programmable" key.intKEYCODE_QKey code constant: 'Q' key.intKEYCODE_RKey code constant: 'R' key.intKEYCODE_RIGHT_BRACKETKey code constant: ']' key.intKEYCODE_ROKey code constant: Japanese Ro key.intKEYCODE_SKey code constant: 'S' key.intKEYCODE_SCROLL_LOCKKey code constant: Scroll Lock key.intKEYCODE_SEARCHKey code constant: Search key.intKEYCODE_SEMICOLONKey code constant: ';' key.intKEYCODE_SETTINGSKey code constant: Settings key.intKEYCODE_SHIFT_LEFTKey code constant: Left Shift modifier key.intKEYCODE_SHIFT_RIGHTKey code constant: Right Shift modifier key.intKEYCODE_SLASHKey code constant: '/' key.intKEYCODE_SLEEPKey code constant: Sleep key.intKEYCODE_SOFT_LEFTKey code constant: Soft Left key.intKEYCODE_SOFT_RIGHTKey code constant: Soft Right key.intKEYCODE_SPACEKey code constant: Space key.intKEYCODE_STARKey code constant: '*' key.intKEYCODE_STB_INPUTKey code constant: Set-top-box input key.intKEYCODE_STB_POWERKey code constant: Set-top-box power key.intKEYCODE_SWITCH_CHARSETKey code constant: Switch Charset modifier key.intKEYCODE_SYMKey code constant: Symbol modifier key.intKEYCODE_SYSRQKey code constant: System Request / Print Screen key.intKEYCODE_TKey code constant: 'T' key.intKEYCODE_TABKey code constant: Tab key.intKEYCODE_TVKey code constant: TV key.intKEYCODE_TV_ANTENNA_CABLEKey code constant: Antenna/Cable key.intKEYCODE_TV_AUDIO_DESCRIPTIONKey code constant: Audio description key.intKEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWNKey code constant: Audio description mixing volume down key.intKEYCODE_TV_AUDIO_DESCRIPTION_MIX_UPKey code constant: Audio description mixing volume up key.intKEYCODE_TV_CONTENTS_MENUKey code constant: Contents menu key.intKEYCODE_TV_DATA_SERVICEKey code constant: TV data service key.intKEYCODE_TV_INPUTKey code constant: TV input key.intKEYCODE_TV_INPUT_COMPONENT_1Key code constant: Component #1 key.intKEYCODE_TV_INPUT_COMPONENT_2Key code constant: Component #2 key.intKEYCODE_TV_INPUT_COMPOSITE_1Key code constant: Composite #1 key.intKEYCODE_TV_INPUT_COMPOSITE_2Key code constant: Composite #2 key.intKEYCODE_TV_INPUT_HDMI_1Key code constant: HDMI #1 key.intKEYCODE_TV_INPUT_HDMI_2Key code constant: HDMI #2 key.intKEYCODE_TV_INPUT_HDMI_3Key code constant: HDMI #3 key.intKEYCODE_TV_INPUT_HDMI_4Key code constant: HDMI #4 key.intKEYCODE_TV_INPUT_VGA_1Key code constant: VGA #1 key.intKEYCODE_TV_MEDIA_CONTEXT_MENUKey code constant: Media context menu key.intKEYCODE_TV_NETWORKKey code constant: Toggle Network key.intKEYCODE_TV_NUMBER_ENTRYKey code constant: Number entry key.intKEYCODE_TV_POWERKey code constant: TV power key.intKEYCODE_TV_RADIO_SERVICEKey code constant: Radio key.intKEYCODE_TV_SATELLITEKey code constant: Satellite key.intKEYCODE_TV_SATELLITE_BSKey code constant: BS key.intKEYCODE_TV_SATELLITE_CSKey code constant: CS key.intKEYCODE_TV_SATELLITE_SERVICEKey code constant: BS/CS key.intKEYCODE_TV_TELETEXTKey code constant: Teletext key.intKEYCODE_TV_TERRESTRIAL_ANALOGKey code constant: Analog Terrestrial key.intKEYCODE_TV_TERRESTRIAL_DIGITALKey code constant: Digital Terrestrial key.intKEYCODE_TV_TIMER_PROGRAMMINGKey code constant: Timer programming key.intKEYCODE_TV_ZOOM_MODEKey code constant: Zoom mode key.intKEYCODE_UKey code constant: 'U' key.intKEYCODE_UNKNOWNKey code constant: Unknown key code.intKEYCODE_VKey code constant: 'V' key.intKEYCODE_VOICE_ASSISTKey code constant: Voice Assist key.intKEYCODE_VOLUME_DOWNKey code constant: Volume Down key.intKEYCODE_VOLUME_MUTEKey code constant: Volume Mute key.intKEYCODE_VOLUME_UPKey code constant: Volume Up key.intKEYCODE_WKey code constant: 'W' key.intKEYCODE_WAKEUPKey code constant: Wakeup key.intKEYCODE_WINDOWKey code constant: Window key.intKEYCODE_XKey code constant: 'X' key.intKEYCODE_YKey code constant: 'Y' key.intKEYCODE_YENKey code constant: Japanese Yen key.intKEYCODE_ZKey code constant: 'Z' key.intKEYCODE_ZENKAKU_HANKAKUKey code constant: Japanese full-width / half-width key.intKEYCODE_ZOOM_INKey code constant: Zoom in key.intKEYCODE_ZOOM_OUTKey code constant: Zoom out key.intMAX_KEYCODEThis constant was deprecated in API level 3. There are now more than MAX_KEYCODE keycodes. UsegetMaxKeyCode() instead.intMETA_ALT_LEFT_ON

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

intMETA_ALT_MASKThis mask is a combination of META_ALT_ON,META_ALT_LEFT_ON andMETA_ALT_RIGHT_ON.intMETA_ALT_ON

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

intMETA_ALT_RIGHT_ON

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

intMETA_CAPS_LOCK_ON

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

intMETA_CTRL_LEFT_ON

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

intMETA_CTRL_MASKThis mask is a combination of META_CTRL_ON,META_CTRL_LEFT_ON andMETA_CTRL_RIGHT_ON.intMETA_CTRL_ON

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

intMETA_CTRL_RIGHT_ON

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

intMETA_FUNCTION_ON

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

intMETA_META_LEFT_ON

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

intMETA_META_MASKThis mask is a combination of META_META_ON,META_META_LEFT_ON andMETA_META_RIGHT_ON.intMETA_META_ON

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

intMETA_META_RIGHT_ON

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

intMETA_NUM_LOCK_ON

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

intMETA_SCROLL_LOCK_ON

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

intMETA_SHIFT_LEFT_ON

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

intMETA_SHIFT_MASKThis mask is a combination of META_SHIFT_ON,META_SHIFT_LEFT_ON andMETA_SHIFT_RIGHT_ON.intMETA_SHIFT_ON

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

intMETA_SHIFT_RIGHT_ON

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

intMETA_SYM_ON

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


是扥


0 0
原创粉丝点击