How to get Space key to behave like Enter on a Button in Android

Cross posting from the Xamarin.Forms forum, as this is Android-specific...

When using a physical keyboard on an Android device, the Enter/Return key activates a button that has the focus (even if you can't see that it has the focus). I would like to have the Space key do the same thing. I already have a custom ButtonRenderer for other purposes, and assume that handling the Space key can be done in the ButtonRenderer. I'm not currently an Android person - can anybody provide any guidance as to how to receive key events in a ButtonRenderer pls?

Best Answer

Answers

  • DerProgrammiererDerProgrammierer DEMember ✭✭✭

    @JohnHardman I'm trying to achieve something similar... I want to navigate through items in a listview with the arrow keys (this is working by default in UWP) and set the checkboxes of items to selected with the space key.

    So far I haven't found a way to do it yet... If I do I will post it here, maybe it will help you.

  • JohnHardmanJohnHardman GBUniversity mod
    edited August 2018

    Many thanks Kym.

    I added a test for e.Action == KeyEventActions.Up as well.

    Seems to work so far :-)

  • hopesureshhopesuresh Member

    Thanks Mr.john

Sign In or Register to comment.