Reputation: 4930
I'm trying to use the Soft Keyboard on a SurfaceView in my game. Problem is I can't handle onKey events.
I've tried implementing an OnKeyListener on my view, and overriding:
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
Log.w("Key", "Key Pressed");
return true;
}
But I don't receive any key events.
Using
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
Log.w("Key", "Key Pressed");
return true;
}
Doesn't work either.
Upvotes: 0
Views: 652
Reputation: 4930
Turned out I had to specify the following on the view constructor hook:
setFocusable(true);
setFocusableInTouchMode(true);
since input events are only sent to the focused view.
Upvotes: 1