Search code examples
blazormauikeyboard-eventsmacos-venturamaui-blazor

Keyboard Events Not Triggering in Input Element and InputText Component on macOS


The keyboard events, such as @onkeydown, @onkeyup, and @onkeypress, are not triggering for the input element or InputText component in a MAUI Blazor app running on macOS. While these events work fine on Windows machines.

<input @onkeydown="KeydownHandler" @onkeypress="KeyPressHandler" @onkeyup="KeyUpHandler" @onfocus="FocusHandler"/>

@code {

    public string ComboFieldsDimensionsAll_SelectedItem;

    public void KeydownHandler()
    {
    }

    public void KeyPressHandler()
    {
    }

    public void KeyUpHandler()
    {
    }

    public void FocusHandler()
    {
    }
}

Steps to Reproduce

  1. Run the attached MAUI app.
  2. Focus on the input element.
  3. Type any alphanumeric key inside it.

**Public project repo **

https://github.com/Deepak-Ramakrisnan/MAUI-KeyBoard

Expected Result: The keyboard events should trigger for every valid key press.

Actual Result: None of the keyboard events are triggered for the key inputs.


Solution

  • I tested your sample on Mac Catalyst with macOS Monterey 12.6 and it can trigger the keyboard events such as @onkeydown, @onkeyup, and @onkeypress as expected.

    Unfortunately, it is not supported yet on macOS Ventura. We are working on upgrading our infrastructure fully to macOS Ventura as Xcode 14.3 now requires it and has proven to be a challenge but we are making good progress on it. For more details, you can refer to [META] Xcode 14.3 Support for Xamarin, .NET 6/7 and MAUI #17561.

    Additionally, I noticed that you raised a new issue: Keyboard Events Not Triggering in Input Element and InputText Component on macOS on Github. You can continue following up on that thread.