码迷,mamicode.com
首页 > 移动开发 > 详细

Android虚拟键盘上下左右键按下和弹起的响应事件

时间:2015-08-25 16:20:34      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:

 

 

 

 

  // 按键按下,所触发的事件 
    public boolean onKeyDown(int keyCode, KeyEvent event) { 
        switch (keyCode) { 
        case KeyEvent.KEYCODE_DPAD_CENTER: 
            display("中键被按下"); 
            break; 
        case KeyEvent.KEYCODE_DPAD_DOWN: 
            display("下键被按下"); 
            break; 
        case KeyEvent.KEYCODE_DPAD_LEFT: 
            display("左键被按下"); 
            break; 
        case KeyEvent.KEYCODE_DPAD_RIGHT: 
            display("右键被按下"); 
            break; 
        case KeyEvent.KEYCODE_DPAD_UP: 
            display("上键被按下"); 
            break; 
        } 
        return super.onKeyDown(keyCode, event); 
    } 
 
 
    // 按键弹起,所触发的事件 
    public boolean onKeyUp(int keyCode, KeyEvent event) { 
        switch (keyCode) { 
        case KeyEvent.KEYCODE_DPAD_CENTER: 
            display("中键被弹起"); 
            break; 
        case KeyEvent.KEYCODE_DPAD_DOWN: 
            display("下键被弹起"); 
            break; 
        case KeyEvent.KEYCODE_DPAD_LEFT: 
            display("左键被弹起"); 
            break; 
        case KeyEvent.KEYCODE_DPAD_RIGHT: 
            display("右键被弹起"); 
            break; 
        case KeyEvent.KEYCODE_DPAD_UP: 
            display("上键被弹起"); 
            break; 
        } 
        return super.onKeyUp(keyCode, event); 
    }  

 

  // 按键按下,所触发的事件 
    public boolean onKeyDown(int keyCode, KeyEvent event) { 
        switch (keyCode) { 
        case KeyEvent.KEYCODE_DPAD_CENTER: 
            display("中键被按下"); 
            break; 
        case KeyEvent.KEYCODE_DPAD_DOWN: 
            display("下键被按下"); 
            break; 
        case KeyEvent.KEYCODE_DPAD_LEFT: 
            display("左键被按下"); 
            break; 
        case KeyEvent.KEYCODE_DPAD_RIGHT: 
            display("右键被按下"); 
            break; 
        case KeyEvent.KEYCODE_DPAD_UP: 
            display("上键被按下"); 
            break; 
        } 
        return super.onKeyDown(keyCode, event); 
    } 
 
 
    // 按键弹起,所触发的事件 
    public boolean onKeyUp(int keyCode, KeyEvent event) { 
        switch (keyCode) { 
        case KeyEvent.KEYCODE_DPAD_CENTER: 
            display("中键被弹起"); 
            break; 
        case KeyEvent.KEYCODE_DPAD_DOWN: 
            display("下键被弹起"); 
            break; 
        case KeyEvent.KEYCODE_DPAD_LEFT: 
            display("左键被弹起"); 
            break; 
        case KeyEvent.KEYCODE_DPAD_RIGHT: 
            display("右键被弹起"); 
            break; 
        case KeyEvent.KEYCODE_DPAD_UP: 
            display("上键被弹起"); 
            break; 
        } 
        return super.onKeyUp(keyCode, event); 
    } 

Android虚拟键盘上下左右键按下和弹起的响应事件

标签:

原文地址:http://www.cnblogs.com/wjhblogs/p/4757300.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!