Skip to content

Expose Android Activity OnKey* overrides via ConfigureLifecycleEvents #31205

@PureWeen

Description

@PureWeen

Description

Request to add more ConfigureLifecycleEvents for Android that expose all of the OnKey* overrides available on an Android Activity. This would allow developers using .NET MAUI to handle key events (such as OnKeyDown, OnKeyUp, OnKeyLongPress, etc.) directly in their MAUI applications via lifecycle events, providing finer control over hardware key interactions.

Public API Changes

Add new lifecycle event delegates to ConfigureLifecycleEvents for Android to surface all OnKey* methods:

  • OnKeyDown
  • OnKeyUp
  • OnKeyLongPress
  • OnKeyMultiple
  • OnKeyShortcut
  • OnKeyPreIme
    These would be accessible through the Android-specific lifecycle configuration API, similar to other events exposed currently.

Intended Use-Case

This feature would allow apps to react to hardware key events (volume buttons, keyboard, etc.) in a cross-platform way. For example, games, accessibility tools, or apps requiring custom key handling could implement platform-specific logic without needing to subclass native Android activities or handlers.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions