I'm trying to write text in `Canvas`. As I need to show the soft keyboard to write text, I added an `EditText` to my Activity with 0 width. I also implemented a TextWatcher to get the text entered into the `EditText`. With this trick, I can show the soft keyboard whenever I like with this code : 

```
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(myEditText, InputMethodManager.SHOW_IMPLICIT);

```

Like this I'm able to know what the user is writing and to write the text inside my `Canvas`.

Now... this becomes tricky when the user would like to stop writing (or let say, anchor the text in the canvas definitely). What I thought is that he could press 'Enter'. So I tried to implement some way to catch the key events. Without any success so far. 

Here is my actual code. This method is called when I would like to start writing. 'edit' is an `EditText`. 

```
public void handleUp(final Paint myPaint) {
                edit.setFocusable(true);
                edit.setFocusableInTouchMode(true);
                edit.requestFocus();
                edit.addTextChangedListener(new Watcher());
                edit.setImeOptions(EditorInfo.IME_ACTION_GO);
                edit.setOnEditorActionListener(new OnEditorActionListener() {
                    public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
                        Log.d("MyApp", "key pressed");
                        Paint localPaint = new Paint();
                        mCanvas.drawText(edit.getText().toString(), mX, mY, localPaint);
                        return false;
                    }
                });
                edit.setOnKeyListener(new OnKeyListener() {
                    public boolean onKey(View v, int keyCode, KeyEvent event) {

                        Log.d("MyApp", "key pressed");
                        if (keyCode == KeyEvent.ACTION_DOWN) {
                            Paint localPaint = new Paint();
                            mCanvas.drawText(edit.getText().toString(), mX, mY, localPaint);
                            return true;
                        }
                        return false;
                    }
                });
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.showSoftInput(edit, InputMethodManager.SHOW_IMPLICIT);

            }

```

When I debug my app I never reach check points that I have put on my `Log()` and can't see any message in my Logs neither. I have seen many posts on StackOverFlow where this kind of implementation is used by I can't figure out why it fails here.

Thank you
['https://Stackoverflow.com/questions/15773588', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1685143/']
You override the dispatchKeyEvent to get the Enter key 

```
@Override
public boolean dispatchKeyEvent(KeyEvent event)
{
    if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)
    {
        // Do whatever you want
    }

    return super.dispatchKeyEvent(event);
}

```
Okay so finally the reason nothing worked was because my `EditText` had a width of 0. When I put width and height to 1. Setting visibility to `View.INVISIBLE` doesn't work in this case. 

By the way, the three Listener (OnEditorActionListener, OnKeyListener and Overriding dispatchKeyEvent) get the callbacks. But I'll use `OnEditorActionListener` because it's the only one getting only one callback. The two others get several callbacks which is problematic.