I have an edittext
where I'm trying to over ride the default input of physical keys to replace with custom input for each key. My code works fine to add the input that I want, but I cannot seem to suppress the default input, which shows up alongside my input. At the present, I am scanning the text, removing the unwanted input, replacing the text, and repositioning the caret - but this solution is highly impractical.
Just for context - I'm targeting a device that has a traditional number keypad, and does not have support for standard android input procedures. The device comes preinstalled with Latin and Korean input, and I am trying to create a T9 solution for other languages, not preinstalled. This method seems to be the only way to do it on this device.
How can I suppress the default input?
Similar to this question, but for Android.
Skipping over my temporary solution, here is the code that intercepts the key events. I need to suppress the default input at the indicated position in the code:
public boolean onKeyUp(int KeyCode, KeyEvent event){
super.onKeyUp(KeyCode, event);
if (KeyCode>6 && KeyCode<19){
//todo: suppress default input here!
switch (KeyCode){
case 7: buttonHandler(R.id.Button0); break;
case 8: buttonHandler(R.id.Button1); break;
case 9: buttonHandler(R.id.Button2); break;
case 10: buttonHandler(R.id.Button3); break;
case 11: buttonHandler(R.id.Button4); break;
case 12: buttonHandler(R.id.Button5); break;
case 13: buttonHandler(R.id.Button6); break;
case 14: buttonHandler(R.id.Button7); break;
case 15: buttonHandler(R.id.Button8); break;
case 16: buttonHandler(R.id.Button9); break;
case 17: buttonHandler(R.id.ButtonStar); break;
case 18: buttonHandler(R.id.ButtonHash); break;
}
}
}