zoukankan      html  css  js  c++  java
  • [JavaME]如何确认用户连续按键指的是哪一个字符

    有点像手机英文输入法中,按2一下代表a,连按两下代表b,连续三下代表c。
    据说,你可以用timertask来做这件事情。

    我的一个设想是(未曾代码试验过,错了请指出):

    用户按键“1”,那么计数他按了多少下,根据他按的次数去你事先写好的数组中查到是哪一个字符。如果用户迟迟没有再按下去,那么到了一定时间,就应该确认他的输入了,timer呢就调用confirmCharacter()。

    String[] values = {".,1","abc","def" };
     
    keyPressed(keyCode) 
    {
      
    int index = keyCode - KEY_NUM0;
      
    if(index == lastindex) charselected++;
      
    else lastindex = index;
       
    // here reset the key confirmation timer
     
       tempInputString
    +=values[index].char(charselected);
    }

     
    //When timer gets triggered, it calls this method
    void confirmCharacter() {
        inputString 
    = tempInputString;
        lastindex 
    = -1;
    }


  • 相关阅读:
    nginx.conf
    添加分类和标签,级联数据
    使用事物插入数据库
    列表页面常用技巧
    常用TagHelper
    培训指导
    控件数据绑定总结
    快速添加Basic表单
    自动构建表单
    模块制作标准说明
  • 原文地址:https://www.cnblogs.com/zhengyun_ustc/p/278135.html
Copyright © 2011-2022 走看看