Keyboard ease of use in apps with .NET MAUI

Keyboard usability in apps

Why it's important and how .NET MAUI can help

Accessibility plays a central role in modern software development. A particularly important aspect of this is keyboard-friendliness, meaning the ability to operate an app entirely with the keyboard, without needing a mouse or touchscreen. This feature is not only crucial for people with disabilities but also improves the user experience for all users. But how do you ensure that an app is keyboard-friendly? In this article, we explain the basics and show how .NET MAUI helps developers create keyboard-friendly apps.

Web Content Accessibility Guidelines (WCAG)

A good starting point for understanding keyboard accessibility is the Web Content Accessibility Guidelines (WCAG). These globally recognized standards provide clear guidelines on how to design accessible digital content. Particularly relevant is the guideline that all functions of an app must be accessible via a keyboard.

The most important criteria are: 

  • Success criterion 2.1.1 Keyboard: All functions can be operated via a keyboard interface without requiring special timings for individual key presses.
  • Success criterion 2.1.2 No keyboard trap: The keyboard focus can be moved from one part of the page to another, and the user is informed when special keys are needed.
  • Success criterion 2.1.3 Keyboard (without exceptions): All content is fully operable via the keyboard.
  • Success criterion 2.1.4 Keyboard shortcuts: Implemented keyboard shortcuts must be able to be deactivated, reassigned, or only activated when the relevant element is in focus.

.NET MAUI and keyboard ease of use

.NET MAUI helps developers create keyboard-friendly apps. Developers familiar with the keyboard behavior of Xamarin.Forms have therefore noticed several changes made to improve keyboard accessibility in their applications.

Here are three examples of how .NET MAUI makes this easier:

1. Keyboard navigation on modal pages

One of the biggest challenges in developing accessible applications is handling modal pages. These pages appear as an overlay on top of the current page and must be fully accessible, while the underlying page should no longer be accessible. .NET MAUI elegantly solves this problem:

  • Focus upon release: When a modal page appears, the first focusable element on that page receives focus. This ensures that users can interact with the new page immediately.
  • Accessibility of content: All interactive elements on the modal page, including the close or save buttons, are keyboard focusable.
  • Return to the starting point: When the modal page is closed, the focus is returned to the first focusable element of the page below.

Thanks to these mechanisms, .NET MAUI ensures that modal pages can be navigated seamlessly and in a user-friendly manner.

2. Focus/Unfocus on Android

In earlier versions of Android, it wasn't possible to remove focus from an input field without focusing on another element. This led to significant accessibility issues. .NET MAUI offers an improved solution:

  • SoftInputExtensions APIs: Instead of manipulating the focus, developers can use the new SoftInputExtensions API to selectively show and hide the soft keyboard.
  • HideSoftInputOnTapped: This optional feature, introduced in .NET 8, allows users to hide the soft keyboard by simply tapping the page – a handy solution for specific scenarios.
3. Keyboard shortcuts (Keyboard Accelerators)

Another highlight in .NET MAUI is the support for keyboard shortcuts, which not only improve accessibility but also increase the productivity of power users:

  • Easy integration: Developers can integrate keyboard shortcuts into their apps to make menu items and commands quickly and easily accessible. This feature makes navigating and operating the app significantly more efficient and intuitive for users who primarily use the keyboard.

Conclusion: On the way to accessible apps

With .NET MAUI, developing keyboard-accessible applications is easier and more effective than ever before. The framework offers built-in solutions to address common accessibility issues and ensure that all users can benefit equally from the applications.

Source: https://devblogs.microsoft.com/dotnet/the-journey-to-accessible-apps-keyboard-accessible/