Android如何键盘按键响应事件


Android如何键盘按键响应事件测试代码及其说明如下:

  1. /** 
  2.          * Use with setDefaultKeyMode to launch the dialer during default key 
  3.          * handling 将键盘所有的按键传递到拨号 
  4.          */  
  5.         setDefaultKeyMode(DEFAULT_KEYS_DIALER);  
  6.         /** 
  7.          * Use with setDefaultKeyMode to turn off default handling of keys. 
  8.          * 直接丢弃,这种情况你把键盘按穿了也不会有系统理你 
  9.          */  
  10.         setDefaultKeyMode(DEFAULT_KEYS_DISABLE);  
  11.         /** 
  12.          * Use with setDefaultKeyMode to specify that unhandled keystrokes will 
  13.          * start a global search (typically web search, but some platforms may 
  14.          * define alternate methods for global search) 将键盘输入作为搜索内容,进行全局搜索 
  15.          * 保证当前处于英文输入模式,可以通过呼出一个软键盘来改变当前输入模式。 
  16.          */  
  17.         setDefaultKeyMode(DEFAULT_KEYS_SEARCH_GLOBAL);  
  18.         /** 
  19.          * Use with setDefaultKeyMode to specify that unhandled keystrokes will 
  20.          * start an application-defined search. (If the application or activity 
  21.          * does not actually define a search, the the keys will be ignored.) 
  22.          * 将键盘输入作为搜索内容,进行本地搜索,如果本地没有实现自定义搜索,则会被忽略. 
  23.          */  
  24.         setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);  
  25.         /** 
  26.          * Use with setDefaultKeyMode to execute a menu shortcut in default key 
  27.          * handling. That is, the user does not need to hold down the menu key to execute 
  28.          * menu shortcuts. 
  29.          * 将键盘输入作为当前窗体上注册的快捷键,进行快捷键处理 
  30.          */  
  31.         setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);  

相关内容