We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

keydown on mobile device

Hi,

In my Blazor Server Web App that should work exclusively on mobile devices,

I'm trying to intercept the @onkeydown event.

Something like this:

<SfTextBox ShowClearButton="true" Autocomplete="AutoComplete.Off" Type="InputType.Search"
           @onkeydown="OnInputTextBoxKeyDown" />


The problem is that any keydown from a mobile device returns the followeing KeyboardEventArgs:


Am I doing something wrong?

Please provide any suggestions!

Thank you in advance!

Best regards,

Ivan Temelkov



1 Reply

DR Deepak Ramakrishnan Syncfusion Team January 26, 2023 05:06 PM UTC

Hi Ivan,

Greetings …!


"The onKeyDown event in mobile browsers may not provide the desired event arguments, such as the key code or character, due to the limited keyboard options on mobile devices. This is also the intended behavior in native <InputText> elements. An alternate solution for capturing keyboard input on mobile devices is to utilize the Input event, which is triggered whenever a user interacts with a Syncfusion TextBox."


 

@using Syncfusion.Blazor.Inputs

 

 

<SfTextBox ShowClearButton="true" Autocomplete="AutoComplete.Off" Type="InputType.Search"

           Input="OnInputTextBoxKeyDown" />

 

 

@code{

    void OnInputTextBoxKeyDown(InputEventArgs args)

    {

        var key = args.Value;

    }

}



API documentation:
https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Inputs.SfTextBox.html#Syncfusion_Blazor_Inputs_SfTextBox_Input

Thanks,

Deepak R.


Loader.
Live Chat Icon For mobile
Up arrow icon