본문 바로가기

IT개발/안드로이드

안드로이드 키 이벤트 (adb shell로 보내는 법)


Two ways to send key event:
1 adb shell input keyevent KEY_CODE_XXX
keycode can be found on developer.android.com
eg. adb shell input keyevent 4 #send back key to target

2 adb shell sendevent [device] [type]
adb shell sendevent /dev/input/event2 1 102 1 #home key down
adb shell sendevent /dev/input/event2 1 102 0 #home key up
must use the whole combination
Key Name CODE
MENU 229
HOME 102
BACK (back button) 158
CALL (call button) 231
END (end call button) 107

it is also possible to send strings to target by adb shell input and mimic mouse event by adb shell sendevent

--------------------------------------------------------------------------------------

안드로이드 키 코드

http://blog.daum.net/_blog/BlogTypeView.do?blogid=0YKEQ&articleno=18&_bloghome_menu=recenttext#ajax_history_home


기존 값이랑 좀 다르죠? 참고로 적어둡니다.

a       -     z

29     -     54

"0"    -     "9"
7       -     16

BACK BUTTON - 4
MENU BUTTON - 82

UP, DOWN, LEFT, RIGHT
19, 20, 21, 22

SELECT (MIDDLE) BUTTON - 23

SPACE - 62
SHIFT - 59
ENTER - 66
BACKSPACE - 67