Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[WiP] KeyboardGestureRecognizers #16217

@PureWeen

Description

@PureWeen

Description

Enable Keyboard scenarios for custom controls built on top of .NET MAUI.

(Public) API Changes

KeyboardGestureRecognizer

Allow users to react to keyboard events.

Properties

Events

API Description
KeyUp Indicates a KeyUp event is being processed by the given control
KeyDown Indicates a KeyDown event is being processed by the given control
PreviewKeyUp Indicates a KeyUp event is going to happen to a given control. This is the place where you would intercept and redirect a KeyUp event before it happens
PreviewKeyDown Indicates a KeyDown event is going to happen to a given control. This is the place where you would intercept and redirect a KeyDown event before it happens

KeyboardEventArgs

Properties

API Description
Handled When this is marked as true the operating system will stop bubbling this event
Key What is the key that triggered this event

Usage Scenarios

Simple XAML Example

<StackPanel.GestureRecognizers>
  <KeyboardGestureRecognizer KeyDown="OnKeyDown"></KeyboardGestureRecognizer>
</StackPanel.GestureRecognizers>

Modify how arrow keys work

<StackPanel.GestureRecognizers>
  <KeyboardGestureRecognizer PreviewKeyDown="OnPreviewKeyDown"></KeyboardGestureRecognizer>
</StackPanel.GestureRecognizers>
void OnPreviewKeyDown(object sender, KeyboardEventArgs args)
{
    if (args.Key == VirtualKeys.Up)
         args.Handled = true;
}

Backward Compatibility

N/A

Difficulty

High

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions