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

Feature Request: Add OnKeyPress event or an attribute to handle ENTER key presses

I am not able to detect the user hitting the enter key after typing text into the combobox. Ideally, we would either have an OnKeyPress event or an attribute added to the control. I prefer the attribute approach with an attribute named "HandleEnterAsValueChange". Note, this may or may not be part of the ValueChange bug being rolled out tomorrow.

Behavior:
- If user enters text and the value exists in the list of values in the control, then call the ValueChanged event.
- If user enters text and the value does not exist, do nothing

Thanks...VR Architect

1 Reply

SN Sevvandhi Nagulan Syncfusion Team February 5, 2020 04:09 PM UTC

Hi Scott, 

Greetings from Syncfusion support. 

Solution 1: We have checked the reported requirement. We would like to inform you that when you enable the filtering event, the change event will be triggered based on the filtered value while pressing the enter key. If you don't have any records matched, then the change event will not be trigger. 
Solution2: We can achieve the same functionalities using action complete and key-down events. You can enable the filtering, and get the filtered data in the action complete event. 
 
Query: If the user enters text and the value exists in the list of values in the control, then call the ValueChanged event. 

You can get the value in the key down event as mentioned below code snippet, 

public void keydown(KeyboardEventArgs args) 
    { 
        if(args.Code == "Enter" && value.Count != 0) 
        { 
            Console.WriteLine(value[0].Code); 
        } 
        else if (args.Code == "Enter" && value.Count == 0) 
        { 
            Console.WriteLine("No records found"); 
        } 
    } 
 
    public List<Countries> value { get; set; } 
 
    public void onActionComplete(ActionCompleteEventArgs args) 
    { 
        value =  Newtonsoft.Json.JsonConvert.DeserializeObject<List<Countries>>(args.Result.ToString()).ToList<Countries>(); 
 
    } 
    private void onChange(Syncfusion.EJ2.Blazor.DropDowns.ChangeEventArgs<string> args) 
    { 
         
     

Query : If user enters text and the value does not exist, do nothing 

If you do not have any matching record , then value will be returned. 
 
Regards, 
Sevvandhi N 



Loader.
Live Chat Icon For mobile
Up arrow icon