zoukankan      html  css  js  c++  java
  • Android虚拟键盘上下左右键按下和弹起的响应事件

      // 按键按下,所触发的事件 
        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); 
        } 

  • 相关阅读:
    解决页面报错: GEThttp://localhost:8080/favicon.ico 404 (Not Found)
    vs2019快捷键整理
    js保存图片至本地
    PHP输出方式的区别
    js运算精度问题
    Hadoop相关问题
    2015年10月5日 12:49:07
    Hive数据倾斜
    Hadoop错误日志
    使用maven开发MR
  • 原文地址:https://www.cnblogs.com/wjhblogs/p/4757300.html
Copyright © 2011-2022 走看看