The .NET MAUI Community Toolkit is a community-created library that contains .NET MAUI Extensions, Advanced UI/UX Controls, and Behaviors to help make your life as a .NET MAUI developer easier
Android Implementation
iOS Implementation
MacCatalyst Implementation
Windows Implementation
Tizen Implementation
Unit Tests
Samples
Documentation
Summary
Currently, .NET MAUI does not natively support keyboard events such as KeyDown and KeyUp, which were widely used in Windows Forms. This limitation significantly impacts the development of applications that rely on keyboard-based interactions, such as point-of-sale (POS) systems, where keyboard shortcuts are essential for operational efficiency.
Motivation
Why are we doing this?
Developing robust interactive functionality in modern applications, especially those aimed at the commercial environment such as POS systems, often depends on fast responses to input commands. However, the lack of broad support for keyboard events in .NET MAUI imposes substantial limitations on developers and degrades the user experience, forcing the adoption of workarounds such as the use of third-party libraries. These workarounds can lead to inconsistencies, increased development time, and an unnecessarily steep learning curve.
What use cases does it enable?
Implementing native keyboard events allows for a variety of use cases, such as:
Point of Sale (POS) Systems: Where operators can benefit from keyboard shortcuts for quick data entry and navigation, increasing operational efficiency.
Editing and Content Creation Applications: Allowing shortcuts for commands such as saving, loading, and editing, making the user experience more fluid and intuitive.
Games and Simulations: Where an immediate response to keyboard commands can be crucial to gameplay.
What is the expected result?
The expected result of implementing this functionality is a significant improvement in developers' ability to create interactive and efficient user interfaces. This not only improves the end user experience by making applications more intuitive and easier to use, it also aligns .NET MAUI more closely with the functionality available on more traditional, established development platforms such as Windows Forms. This improvement would help to consolidate .NET MAUI as a high-performance and versatile development tool, suitable for a wider range of commercial and entertainment applications.
Detailed Design
Functionality Overview
The proposal consists of integrating a keyboard event model directly into the .NET MAUI core, allowing developers to register and respond to key events in any part of the application, in a consistent and efficient way. This model covers not only simple key events but also key combinations.
Components Involved
MAUI Core: Implementation of basic keyboard events.
Community Toolkit: Extensions to simplify and expand the use of keyboard events, facilitating common implementation of patterns and best practices.
Proposed Design
Base Events: Implement three main events in the lifecycle of a key:
KeyDown : Triggered when a key is pressed.
KeyUp : Triggered when a key is released.
KeyPress : Fired when a key results in a specific character.
Event Classes: KeyEventArgs would be the base class, containing information about the key pressed, including:
Key: The specific key pressed.
Modifiers: Key combinations like Shift, Ctrl, Alt.
Integration with the Community Toolkit
To ensure that the community can easily extend the use of keyboard events, the Community Toolkit could include helpers and behaviors that simplify registering and responding to keyboard events, especially for MVVM commands and other declarative interactions.
Usage Syntax
public MainPage()
{
InitializeComponent();
this.KeyDown += HandleKeyDown;
}
Feature name
Shortcut Events
Link to discussion
1947
Progress tracker
Android Implementation iOS Implementation MacCatalyst Implementation Windows Implementation Tizen Implementation Unit Tests Samples Documentation Summary
Currently, .NET MAUI does not natively support keyboard events such as KeyDown and KeyUp, which were widely used in Windows Forms. This limitation significantly impacts the development of applications that rely on keyboard-based interactions, such as point-of-sale (POS) systems, where keyboard shortcuts are essential for operational efficiency.
Motivation
Why are we doing this?
Developing robust interactive functionality in modern applications, especially those aimed at the commercial environment such as POS systems, often depends on fast responses to input commands. However, the lack of broad support for keyboard events in .NET MAUI imposes substantial limitations on developers and degrades the user experience, forcing the adoption of workarounds such as the use of third-party libraries. These workarounds can lead to inconsistencies, increased development time, and an unnecessarily steep learning curve.
What use cases does it enable?
Implementing native keyboard events allows for a variety of use cases, such as:
Point of Sale (POS) Systems: Where operators can benefit from keyboard shortcuts for quick data entry and navigation, increasing operational efficiency. Editing and Content Creation Applications: Allowing shortcuts for commands such as saving, loading, and editing, making the user experience more fluid and intuitive. Games and Simulations: Where an immediate response to keyboard commands can be crucial to gameplay.
What is the expected result?
The expected result of implementing this functionality is a significant improvement in developers' ability to create interactive and efficient user interfaces. This not only improves the end user experience by making applications more intuitive and easier to use, it also aligns .NET MAUI more closely with the functionality available on more traditional, established development platforms such as Windows Forms. This improvement would help to consolidate .NET MAUI as a high-performance and versatile development tool, suitable for a wider range of commercial and entertainment applications.
Detailed Design
Functionality Overview
The proposal consists of integrating a keyboard event model directly into the .NET MAUI core, allowing developers to register and respond to key events in any part of the application, in a consistent and efficient way. This model covers not only simple key events but also key combinations.
Components Involved
MAUI Core: Implementation of basic keyboard events. Community Toolkit: Extensions to simplify and expand the use of keyboard events, facilitating common implementation of patterns and best practices.
Proposed Design
Base Events: Implement three main events in the lifecycle of a key:
KeyDown : Triggered when a key is pressed. KeyUp : Triggered when a key is released. KeyPress : Fired when a key results in a specific character. Event Classes: KeyEventArgs would be the base class, containing information about the key pressed, including:
Key: The specific key pressed. Modifiers: Key combinations like Shift, Ctrl, Alt. Integration with the Community Toolkit
To ensure that the community can easily extend the use of keyboard events, the Community Toolkit could include helpers and behaviors that simplify registering and responding to keyboard events, especially for MVVM commands and other declarative interactions.
Usage Syntax
public MainPage() { InitializeComponent(); this.KeyDown += HandleKeyDown; }
Drawbacks
No response
Alternatives
No response
Unresolved Questions
No response