Enter Key on Virtual Keyboard

RobertHellestraeRobertHellestrae USMember ✭✭
edited June 2017 in Xamarin.Android

I am working with a WebView on an .axml page, with a goal of intercepting the Enter Key on the virtual keyboard with C# and an Activity (MvvmCross);

After entering in text details on a WebView - and after tapping the Enter Key on the virtual keyboard, the OnKeyDown method is not invoked in debug mode;

Are additional steps required to invoke the OnKeyDown method, such as set up a listener on the View, etc?

I have tried a couple of experiments...

var view = this.BindingInflate(Resource.Layout.fragment_login, null);

view.KeyPress += View_KeyPress;

void View_KeyPress(object sender, View.KeyEventArgs e)
{
if (e.KeyCode == Keycode.Enter)
{
// application - specific code...
}
}

Current Webview code, OnKeyDown Method:

WebView webView;
webView = view.FindViewById(Resource.Id.webView);

public override bool OnKeyDown(Keycode keyCode, KeyEvent e)
{
if (webView != null)
{
if (keyCode == Keycode.Enter)
{
// application - specific code...

        return true;
    }
}
return base.OnKeyDown(keyCode, e);

}

Sign In or Register to comment.