I would like to block pressing keyboard in dropdownlist

Hello Guys,

I would like to block to be changed selected item if I press The Keyboard in The Dropdownlist.
I would like to allow only clicking.
But There is no member about blocking keyboard in dropdownlist API.

Can your guys help me?

1 Reply

KR Keerthana Rajendran Syncfusion Team March 30, 2018 10:10 AM UTC

Hi June,  
  
Thank you for contacting Syncfusion Support.  
  
We don’t have any in-built API to prevent keyboard actions in DropDownList. But you can  override the _OnKeyDown method of DropDownList  as shown below to prevent selection on keyboard action and allow selection only on clicking  
  
<input type="text" id="bikeList" />  
<script type="text/javascript">  
       ej.DropDownList.prototype._OnKeyDown=function (e) {} //remove keydown actions of DropDownList   
        var target;  
        $(function () {  
            // declaration  
            BikeList = [  
                 { empid: "bk1", text: "Apache RTR" }, { empid: "bk2", text: "CBR 150-R" }, { empid: "bk3", text: "CBZ Xtreme" },  
                 { empid: "bk4", text: "Discover" }, { empid: "bk5", text: "Dazzler" }, { empid: "bk6", text: "Flame" },  
                 { empid: "bk7", text: "Fazzer" }, { empid: "bk8", text: "FZ-S" }, { empid: "bk9", text: "Pulsar" },  
                 { empid: "bk10", text: "Shine" }, { empid: "bk11", text: "R15" }, { empid: "bk12", text: "Unicorn" }  
            ];              
            $('#bikeList').ejDropDownList({  
                dataSource: BikeList,  
                fields: { id: "empid", text: "text", value: "text" }  
            });  
        });  
    </script>  
  
Please refer to the given sample  
  
  
Regards,  
Keerthana.  
 


Loader.
Up arrow icon