input keyevent发送按键值【转】

本文介绍了Android中KEYCODE的各种按键值,包括方向键、数字键、功能键等,帮助开发者理解如何处理键盘输入事件。
摘要由CSDN通过智能技术生成

本文转载自:http://blog.csdn.net/moyu123456789/article/details/71209893

1.adb shell进入android设备,执行命令input keyevent keycode即可,例如:input keyevent 3 3为KEYCODE_HOME
2.直接adb shell input keyevent keycode也可以,adb shell input keyevent 3 3为KEYCODE_HOME

 KEYCODE和对应的数值在android源码中定义如下:

[html]  view plain  copy
  1. <span style="font-size:18px;">/** Key code constant: Unknown key code. */  
  2.     public static final int KEYCODE_UNKNOWN         = 0;  
  3.     /** Key code constant: Soft Left key.  
  4.      * Usually situated below the display on phones and used as a multi-function  
  5.      * feature key for selecting a software defined function shown on the bottom left  
  6.      * of the display. */  
  7.     public static final int KEYCODE_SOFT_LEFT       = 1;  
  8.     /** Key code constant: Soft Right key.  
  9.      * Usually situated below the display on phones and used as a multi-function  
  10.      * feature key for selecting a software defined function shown on the bottom right  
  11.      * of the display. */  
  12.     public static final int KEYCODE_SOFT_RIGHT      = 2;  
  13.     /** Key code constant: Home key.  
  14.      * This key is handled by the framework and is never delivered to applications. */  
  15.     public static final int KEYCODE_HOME            = 3;  
  16.     /** Key code constant: Back key. */  
  17.     public static final int KEYCODE_BACK            = 4;  
  18.     /** Key code constant: Call key. */  
  19.     public static final int KEYCODE_CALL            = 5;  
  20.     /** Key code constant: End Call key. */  
  21.     public static final int KEYCODE_ENDCALL         = 6;  
  22.     /** Key code constant: '0' key. */  
  23.     public static final int KEYCODE_0               = 7;  
  24.     /** Key code constant: '1' key. */  
  25.     public static final int KEYCODE_1               = 8;  
  26.     /** Key code constant: '2' key. */  
  27.     public static final int KEYCODE_2               = 9;  
  28.     /** Key code constant: '3' key. */  
  29.     public static final int KEYCODE_3               = 10;  
  30.     /** Key code constant: '4' key. */  
  31.     public static final int KEYCODE_4               = 11;  
  32.     /** Key code constant: '5' key. */  
  33.     public static final int KEYCODE_5               = 12;  
  34.     /** Key code constant: '6' key. */  
  35.     public static final int KEYCODE_6               = 13;  
  36.     /** Key code constant: '7' key. */  
  37.     public static final int KEYCODE_7               = 14;  
  38.     /** Key code constant: '8' key. */  
  39.     public static final int KEYCODE_8               = 15;  
  40.     /** Key code constant: '9' key. */  
  41.     public static final int KEYCODE_9               = 16;  
  42.     /** Key code constant: '*' key. */  
  43.     public static final int KEYCODE_STAR            = 17;  
  44.     /** Key code constant: '#' key. */  
  45.     public static final int KEYCODE_POUND           = 18;  
  46.     /** Key code constant: Directional Pad Up key.  
  47.      * May also be synthesized from trackball motions. */  
  48.     public static final int KEYCODE_DPAD_UP         = 19;  
  49.     /** Key code constant: Directional Pad Down key.  
  50.      * May also be synthesized from trackball motions. */  
  51.     public static final int KEYCODE_DPAD_DOWN       = 20;  
  52.     /** Key code constant: Directional Pad Left key.  
  53.      * May also be synthesized from trackball motions. */  
  54.     public static final int KEYCODE_DPAD_LEFT       = 21;  
  55.     /** Key code constant: Directional Pad Right key.  
  56.      * May also be synthesized from trackball motions. */  
  57.     public static final int KEYCODE_DPAD_RIGHT      = 22;  
  58.     /** Key code constant: Directional Pad Center key.  
  59.      * May also be synthesized from trackball motions. */  
  60.     public static final int KEYCODE_DPAD_CENTER     = 23;  
  61.     /** Key code constant: Volume Up key.  
  62.      * Adjusts the speaker volume up. */  
  63.     public static final int KEYCODE_VOLUME_UP       = 24;  
  64.     /** Key code constant: Volume Down key.  
  65.      * Adjusts the speaker volume down. */  
  66.     public static final int KEYCODE_VOLUME_DOWN     = 25;  
  67.     /** Key code constant: Power key. */  
  68.     public static final int KEYCODE_POWER           = 26;  
  69.     /** Key code constant: Camera key.  
  70.      * Used to launch a camera application or take pictures. */  
  71.     public static final int KEYCODE_CAMERA          = 27;  
  72.     /** Key code constant: Clear key. */  
  73.     public static final int KEYCODE_CLEAR           = 28;  
  74.     /** Key code constant: 'A' key. */  
  75.     public static final int KEYCODE_A               = 29;  
  76.     /** Key code constant: 'B' key. */  
  77.     public static final int KEYCODE_B               = 30;  
  78.     /** Key code constant: 'C' key. */  
  79.     public static final int KEYCODE_C               = 31;  
  80.     /** Key code constant: 'D' key. */  
  81.     public static final int KEYCODE_D               = 32;  
  82.     /** Key code constant: 'E' key. */  
  83.     public static final int KEYCODE_E               = 33;  
  84.     /** Key code constant: 'F' key. */  
  85.     public static final int KEYCODE_F               = 34;  
  86.     /** Key code constant: 'G' key. */  
  87.     public static final int KEYCODE_G               = 35;  
  88.     /** Key code constant: 'H' key. */  
  89.     public static final int KEYCODE_H               = 36;  
  90.     /** Key code constant: 'I' key. */  
  91.     public static final int KEYCODE_I               = 37;  
  92.     /** Key code constant: 'J' key. */  
  93.     public static final int KEYCODE_J               = 38;  
  94.     /** Key code constant: 'K' key. */  
  95.     public static final int KEYCODE_K               = 39;  
  96.     /** Key code constant: 'L' key. */  
  97.     public static final int KEYCODE_L               = 40;  
  98.     /** Key code constant: 'M' key. */  
  99.     public static final int KEYCODE_M               = 41;  
  100.     /** Key code constant: 'N' key. */  
  101.     public static final int KEYCODE_N               = 42;  
  102.     /** Key code constant: 'O' key. */  
  103.     public static final int KEYCODE_O               = 43;  
  104.     /** Key code constant: 'P' key. */  
  105.     public static final int KEYCODE_P               = 44;  
  106.     /** Key code constant: 'Q' key. */  
  107.     public static final int KEYCODE_Q               = 45;  
  108.     /** Key code constant: 'R' key. */  
  109.     public static final int KEYCODE_R               = 46;  
  110.     /** Key code constant: 'S' key. */  
  111.     public static final int KEYCODE_S               = 47;  
  112.     /** Key code constant: 'T' key. */  
  113.     public static final int KEYCODE_T               = 48;  
  114.     /** Key code constant: 'U' key. */  
  115.     public static final int KEYCODE_U               = 49;  
  116.     /** Key code constant: 'V' key. */  
  117.     public static final int KEYCODE_V               = 50;  
  118.     /** Key code constant: 'W' key. */  
  119.     public static final int KEYCODE_W               = 51;  
  120.     /** Key code constant: 'X' key. */  
  121.     public static final int KEYCODE_X               = 52;  
  122.     /** Key code constant: 'Y' key. */  
  123.     public static final int KEYCODE_Y               = 53;  
  124.     /** Key code constant: 'Z' key. */  
  125.     public static final int KEYCODE_Z               = 54;  
  126.     /** Key code constant: ',' key. */  
  127.     public static final int KEYCODE_COMMA           = 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

嵌入式小庄老师

要是觉得不错,就给我点支持吧

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值