1

I am creating a custom keyboard for a Xamarin Android Application. I have it working, and my listener receives the input. My issue is the parameter Android.Views.Keycode. This enumeration does not have all of the possible keys. I have found some of them generate the correct keystroke if the KeyEvent is created with MetaKeyStates.ShiftOn. But even in that I have not found the right combination for the {} keys. There also doesn't appear to be a clear answer to which key or key/MetaState combination maps to backspace, Next, Done, etc.

I have not found documentation that shows which Keyode in conjunction with the required MetaState will generate which key strokes. Does such documentation exists? Does anyone have an exhaustive example showing which Keycode and which metastates create which characters?

Also, in the case of my keyboard, the ! and ? characters will appear on the screen with the normal text. Do I need to use a custom Keycode for them so I can tell the difference between them and the character that would have the same Keycode without a metastate?

1 Answer 1

1

Why are you using keycodes? Those are for hardware buttons. Software keyboards usually use InputConnection.commitText and skip keycodes entirely.

Next, Done, etc are the action button. That's another call on InputConnection- performEditorAction.

Delete is generally done by InputConenction.deleteSurroundingText.

Shifts are generally an internal state and not connected to any keycode.

You're doing everything the wrong way, basically. Here's the android implementation, I assume xamarin has its wrappers. https://developer.android.com/reference/android/view/inputmethod/InputConnection

Sign up to request clarification or add additional context in comments.

1 Comment

In Xamarin when you set up the keyboard it uses KeyboardView.IOnKeyboardActionListener and the OnKey method accepts Android.Views.Keycode. If there is a better way to implement it through Xamarin I am open, but from what I have found this was the Xamarin implementation for a KeyboardView.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.