Question

I know that onTouchEvent() can return the current touch point's x,y in a view, However, when I touch a key on a softkeyboard. the method is not working,

My question is how can I apply onTouchEvent to softkeyboard on Android?

Was it helpful?

Solution

It is not possible to get a touch event for a soft keyboard.

If you want to capture keys as they are entered into an EditText, check out the EditText.addTextChangedListener() function.

Alternatively, try implementing the View.OnKeyListener interface in your Activity, or overriding public boolean dispatchKeyEvent(KeyEvent e), or overriding public boolean onKeyDown(int keyCode, KeyEvent event). In all of those cases, you can check what the keyCode or KeyEvent is and handle it as you wish.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top