how to capture the Hardware BackKey click event when onscreen keyboard is present

364 views Asked by At

I am developing Windows Phone 8 PhoneGap app. When the onscreen keyboard is present, if we click the hardware back key, it closes the onscreen keyboard. But at that time no event is getting fired including BackKeyPress event. May I know how to capture the Hardware BackKey click event when onscreen keyboard is present?

2

There are 2 answers

1
Justice On

If i am right you want to catch the event fired when user presses back key on the phone, then you can override the event for the same

    protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
    {
        base.OnBackKeyPress(e);

        //your logic goes here
    }

If you press the key When the on screen keyboard is present the default behavior is to close the keyboard, you can only catch this event once the keyboard is closed.

If you want to detect the closing of the keyboard you can use the LostFocus event of the textbox or any other similar control that you might be using. hope this helps!

2
fantastik78 On

I don't know if there is a easy way to do this, but you could listen to the TextBox.LostFocus event to know when the keyboard is hidden.

If you have more than one textbox, check if the others didn't get the focus.