Detect OnKeyDown event when the FlexGrid has focus

Posted by: adobozi on 11 August 2025, 5:06 pm EST

    • Post Options:
    • Link

    Posted 11 August 2025, 5:06 pm EST

    My Android project is using a bluetooth keyboard for data entry. All screen navigation is handled via the arrow keys (up, down, left right), Tab key and Back Tab key. I’m able to catch the arrow and tab key presses by overriding the OnKeyDown event in the Android MainActivity (MauiAppCompatActivity). However, when the FlexGrid has focus I can catch only the Back Tab keypress. I need to catch the arrow and tab keys. How can I do that?

    I want handle the arrow and tab key so I can skip read-only rows and cells in the FlexGrid when moving between cells.

  • Posted 13 August 2025, 2:05 pm EST

    Hi,

    Apologies for the delayed response.

    We tried to implement your requirement but were unable to fully meet all aspects of it. We have shared your requirement with the development team to get their insights and will update you as soon as we receive any information.

    [Internal Tracking ID: C1XAML-38523]

    Best Regards,

    Kartik

  • Posted 21 August 2025, 2:31 am EST

    Hi,

    According to the development team, FlexGrid for MAUI supports keyboard navigation with the Left, Right, Up, Down, Tab, and Shift+Tab keys by default. We setup a physical Android device with a Bluetooth keyboard connected to test this and confirmed that FlexGrid supports all of the above navigations.

    Therefore, we are not sure why Shift+Tab to navigate backwards (towards left) is not working on your end. We recommend testing with the latest version of the FlexGrid package: https://www.nuget.org/packages/C1.Maui.Grid/9.0.20251.1113


    Regarding your requirement to skip read-only cells during keyboard navigation, this is not directly supported. The only workaround is to override the OnKeyDown method of the GridCellFactory, and then manually implement cell-navigation for the Left, Right, Up, Down, Tab, and Shift+Tab keys.

    We have attached a sample project demonstrating this approach. The UpdateCursor method in the CustomGridCellFactory class contains the navigation logic, which you can modify to skip the read-only cells.

    KeyboardNavigationDemo.zip

    Best Regards,

    Kartik

  • Posted 21 August 2025, 11:57 am EST

    Thank you for the navigation sample. I found the CellFactory.OnKeyDown event earlier this week and was in the middle of implementing the navigation. Your sample helps a lot.

    Regarding the shift-tab, when I posted this topic I wasn’t aware of the CellFactory.OnKeyDown event. I was using the MAUI MainActivity.OnKeyDown. When the FlexGrid has focus pressing shift+tab didn’t trigger the MainActivity.OnKeyDown. It’s a moot point now that I can use the CellFactory.OnKeyDown.

    Thank you again,

    Attila

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels