Android KeyCode Reference Table

Phone Keys

KEYCODE_CALL Dial Key 5
KEYCODE_ENDCALL Hang Up Key 6
KEYCODE_HOME Home Key 3
KEYCODE_MENU Menu Key 82
KEYCODE_BACK Back Key 4
KEYCODE_SEARCH Search Key 84
KEYCODE_CAMERA Camera Key 27
KEYCODE_FOCUS Camera Focus Key 80
KEYCODE_POWER Power Key 26
KEYCODE_NOTIFICATION Notification Key 83
KEYCODE_MUTE Mute Key 91
KEYCODE_VOLUME_MUTE Volume Mute Key 164
KEYCODE_VOLUME_UP Volume Up Key 24
KEYCODE_VOLUME_DOWN Volume Down Key 25

Control Keys

KEYCODE_ENTER Enter Key 66
KEYCODE_ESCAPE ESC Key 111
KEYCODE_DPAD_CENTER Navigation Key Confirm Key 23
KEYCODE_DPAD_UP Navigation Key Up 19
KEYCODE_DPAD_DOWN Navigation Key Down 20
KEYCODE_DPAD_LEFT Navigation Key Left 21
KEYCODE_DPAD_RIGHT Navigation Key Right 22
KEYCODE_MOVE_HOME Move Cursor to Start Key 122
KEYCODE_MOVE_END Move Cursor to End Key 123
KEYCODE_PAGE_UP Page Up Key 92
KEYCODE_PAGE_DOWN Page Down Key 93
KEYCODE_DEL Delete Key 67
KEYCODE_FORWARD_DEL Forward Delete Key 112
KEYCODE_INSERT Insert Key 124
KEYCODE_TAB Tab Key 61
KEYCODE_NUM_LOCK Num Lock Key 143
KEYCODE_CAPS_LOCK Caps Lock Key 115
KEYCODE_BREAK Break/Pause Key 121
KEYCODE_SCROLL_LOCK Scroll Lock Key 116
KEYCODE_ZOOM_IN Zoom In Key 168
KEYCODE_ZOOM_OUT Zoom Out Key 169

Combination Keys

KEYCODE_ALT_LEFT Alt+Left
KEYCODE_ALT_RIGHT Alt+Right
KEYCODE_CTRL_LEFT Control+Left
KEYCODE_CTRL_RIGHT Control+Right
KEYCODE_SHIFT_LEFT Shift+Left
KEYCODE_SHIFT_RIGHT Shift+Right

Basic

KEYCODE_0 Key '0' 7
KEYCODE_1 Key '1' 8
KEYCODE_2 Key '2' 9
KEYCODE_3 Key '3' 10
KEYCODE_4 Key '4' 11
KEYCODE_5 Key '5' 12
KEYCODE_6 Key '6' 13
KEYCODE_7 Key '7' 14
KEYCODE_8 Key '8' 15
KEYCODE_9 Key '9' 16
KEYCODE_A Key 'A' 29
KEYCODE_B Key 'B' 30
KEYCODE_C Key 'C' 31
KEYCODE_D Key 'D' 32
KEYCODE_E Key 'E' 33
KEYCODE_F Key 'F' 34
KEYCODE_G Key 'G' 35
KEYCODE_H Key 'H' 36
KEYCODE_I Key 'I' 37
KEYCODE_J Key 'J' 38
KEYCODE_K Key 'K' 39
KEYCODE_L Key 'L' 40
KEYCODE_M Key 'M' 41
KEYCODE_N Key 'N' 42
KEYCODE_O Key 'O' 43
KEYCODE_P Key 'P' 44
KEYCODE_Q Key 'Q' 45
KEYCODE_R Key 'R' 46
KEYCODE_S Key 'S' 47
KEYCODE_T Key 'T' 48
KEYCODE_U Key 'U' 49
KEYCODE_V Key 'V' 50
KEYCODE_W Key 'W' 51
KEYCODE_X Key 'X' 52
KEYCODE_Y Key 'Y' 53
KEYCODE_Z Key 'Z' 54

Symbols

KEYCODE_PLUS Key '+'
KEYCODE_MINUS Key '-'
KEYCODE_STAR Key '*'
KEYCODE_SLASH Key '/'
KEYCODE_EQUALS Key '='
KEYCODE_AT Key '@'
KEYCODE_POUND Key '#'
KEYCODE_APOSTROPHE Key ''' (single quote)
KEYCODE_BACKSLASH Key '\'
KEYCODE_COMMA Key ','
KEYCODE_PERIOD Key '.'
KEYCODE_LEFT_BRACKET Key '['
KEYCODE_RIGHT_BRACKET Key ']'
KEYCODE_SEMICOLON Key ';'
KEYCODE_GRAVE Key '`'
KEYCODE_SPACE Space Key

Numpad

KEYCODE_NUMPAD_0 Numpad Key '0'
KEYCODE_NUMPAD_1 Numpad Key '1'
KEYCODE_NUMPAD_2 Numpad Key '2'
KEYCODE_NUMPAD_3 Numpad Key '3'
KEYCODE_NUMPAD_4 Numpad Key '4'
KEYCODE_NUMPAD_5 Numpad Key '5'
KEYCODE_NUMPAD_6 Numpad Key '6'
KEYCODE_NUMPAD_7 Numpad Key '7'
KEYCODE_NUMPAD_8 Numpad Key '8'
KEYCODE_NUMPAD_9 Numpad Key '9'
KEYCODE_NUMPAD_ADD Numpad Key '+'
KEYCODE_NUMPAD_SUBTRACT Numpad Key '-'
KEYCODE_NUMPAD_MULTIPLY Numpad Key '*'
KEYCODE_NUMPAD_DIVIDE Numpad Key '/'
KEYCODE_NUMPAD_EQUALS Numpad Key '='
KEYCODE_NUMPAD_COMMA Numpad Key ','
KEYCODE_NUMPAD_DOT Numpad Key '.'
KEYCODE_NUMPAD_LEFT_PAREN Numpad Key '('
KEYCODE_NUMPAD_RIGHT_PAREN Numpad Key ')'
KEYCODE_NUMPAD_ENTER Numpad Key Enter

Function Keys

KEYCODE_F1 Key F1
KEYCODE_F2 Key F2
KEYCODE_F3 Key F3
KEYCODE_F4 Key F4
KEYCODE_F5 Key F5
KEYCODE_F6 Key F6
KEYCODE_F7 Key F7
KEYCODE_F8 Key F8
KEYCODE_F9 Key F9
KEYCODE_F10 Key F10
KEYCODE_F11 Key F11
KEYCODE_F12 Key F12

Multimedia Keys

KEYCODE_MEDIA_PLAY Multimedia Play Key
KEYCODE_MEDIA_STOP Multimedia Stop Key
KEYCODE_MEDIA_PAUSE Multimedia Pause Key
KEYCODE_MEDIA_PLAY_PAUSE Multimedia Play/Pause Key
KEYCODE_MEDIA_FAST_FORWARD Multimedia Fast Forward Key
KEYCODE_MEDIA_REWIND Multimedia Rewind Key
KEYCODE_MEDIA_NEXT Multimedia Next Track Key
KEYCODE_MEDIA_PREVIOUS Multimedia Previous Track Key
KEYCODE_MEDIA_CLOSE Multimedia Close Key
KEYCODE_MEDIA_EJECT Multimedia Eject Key
KEYCODE_MEDIA_RECORD Multimedia Record Key

Game Controller Keys

KEYCODE_BUTTON_1 Generic Game Controller Button #1
KEYCODE_BUTTON_2 Generic Game Controller Button #2
KEYCODE_BUTTON_3 Generic Game Controller Button #3
KEYCODE_BUTTON_4 Generic Game Controller Button #4
KEYCODE_BUTTON_5 Generic Game Controller Button #5
KEYCODE_BUTTON_6 Generic Game Controller Button #6
KEYCODE_BUTTON_7 Generic Game Controller Button #7
KEYCODE_BUTTON_8 Generic Game Controller Button #8
KEYCODE_BUTTON_9 Generic Game Controller Button #9
KEYCODE_BUTTON_10 Generic Game Controller Button #10
KEYCODE_BUTTON_11 Generic Game Controller Button #11
KEYCODE_BUTTON_12 Generic Game Controller Button #12
KEYCODE_BUTTON_13 Generic Game Controller Button #13
KEYCODE_BUTTON_14 Generic Game Controller Button #14
KEYCODE_BUTTON_15 Generic Game Controller Button #15
KEYCODE_BUTTON_16 Generic Game Controller Button #16
KEYCODE_BUTTON_A Game Controller Button A
KEYCODE_BUTTON_B Game Controller Button B
KEYCODE_BUTTON_C Game Controller Button C
KEYCODE_BUTTON_X Game Controller Button X
KEYCODE_BUTTON_Y Game Controller Button Y
KEYCODE_BUTTON_Z Game Controller Button Z
KEYCODE_BUTTON_L1 Game Controller Button L1
KEYCODE_BUTTON_L2 Game Controller Button L2
KEYCODE_BUTTON_R1 Game Controller Button R1
KEYCODE_BUTTON_R2 Game Controller Button R2
KEYCODE_BUTTON_MODE Game Controller Button Mode
KEYCODE_BUTTON_SELECT Game Controller Button Select
KEYCODE_BUTTON_START Game Controller Button Start
KEYCODE_BUTTON_THUMBL Left Thumb Button
KEYCODE_BUTTON_THUMBR Right Thumb Button

To Be Verified

KEYCODE_NUM Number Modifier Key
KEYCODE_INFO Info Key
KEYCODE_APP_SWITCH App Switch Key
KEYCODE_BOOKMARK Bookmark Key
KEYCODE_AVR_INPUT A/V Receiver Input Key
KEYCODE_AVR_POWER A/V Receiver Power Key
KEYCODE_CAPTIONS Toggle Captions Key
KEYCODE_CHANNEL_DOWN Channel Down Key
KEYCODE_CHANNEL_UP Channel Up Key
KEYCODE_CLEAR Clear Key
KEYCODE_DVR DVR Key
KEYCODE_ENVELOPE Envelope Special Function Key
KEYCODE_EXPLORER Explorer Special Function Key
KEYCODE_FORWARD Forward Key
KEYCODE_FORWARD_DEL Forward Delete Key
KEYCODE_FUNCTION Function Modifier Key
KEYCODE_GUIDE Guide Key
KEYCODE_HEADSETHOOK Headset Hook Key
KEYCODE_META_LEFT Left Meta Modifier Key
KEYCODE_META_RIGHT Right Meta Modifier Key
KEYCODE_PICTSYMBOLS Picture Symbols Modifier Key
KEYCODE_PROG_BLUE Blue "programmable" Key
KEYCODE_PROG_GREEN Green "programmable" Key
KEYCODE_PROG_RED Red "programmable" Key
KEYCODE_PROG_YELLOW Yellow "programmable" Key
KEYCODE_SETTINGS Settings Key
KEYCODE_SOFT_LEFT Soft Left Key
KEYCODE_SOFT_RIGHT Soft Right Key
KEYCODE_STB_INPUT Set-top-box Input Key
KEYCODE_STB_POWER Set-top-box Power Key
KEYCODE_SWITCH_CHARSET Switch Charset Modifier Key
KEYCODE_SYM Symbol Modifier Key
KEYCODE_SYSRQ System Request/Print Screen Key
KEYCODE_TV TV Key
KEYCODE_TV_INPUT TV Input Key
KEYCODE_TV_POWER TV Power Key
KEYCODE_WINDOW Window Key
KEYCODE_UNKNOWN Unknown Key

Android KeyCode Reference Table - Android Key Code Reference and Mapping

In Android development, understanding the KeyCode corresponding to each key is fundamental for handling key events. This article provides a complete Android KeyCode reference table to help developers quickly find the KeyCode values for common keys. Whether physical keys, virtual keys, or function keys, the corresponding KeyCode can be found in this table.

What is Android KeyCode?

Android KeyCode is an integer value representing different keys on the device. Each key (such as "back key," "volume up key") has a unique KeyCode used to process user input events. KeyCodes are very important when writing key event listeners.

Common Android KeyCode Reference Table

Below are the common keys in Android and their corresponding KeyCode values:

Key Name KeyCode Value Description
Back Key 4 Physical back key, used to return to the previous level
Volume Up Key 24 Volume increase key
Volume Down Key 25 Volume decrease key
Power Key 26 Device power key
HOME Key 3 Return to the home screen
MENU Key 82 Pop-up menu
Camera Key 27 Launch camera
Search Key 84 Launch search functionality
Forward Key 92 Browser forward key
Backward Key 93 Browser backward key
Up and Down Arrow Keys 19, 20 Navigation keys, up and down arrows
Left and Right Arrow Keys 21, 22 Navigation keys, left and right arrows

How to Use KeyCode in Android?

In an Android application, you can obtain the KeyCode by listening for key events. For example, when the user presses the back key, you can determine the specific action by checking the KeyCode value:


@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        // Handle back key down event
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

Conclusion

Understanding and utilizing Android KeyCode is foundational knowledge in Android development, especially when handling key events. By mastering Android key codes and KeyCode mapping, you can precisely control user interactions and optimize the user experience of your applications.

Your footpath:
Choose Language