catch keyup or keydown event for dropdownlist

4 posts, 0 answers
  1. yaron
    yaron avatar
    2 posts
    Member since:
    Oct 2012

    Posted 05 Nov 2012 Link to this post

    Hi,
    I use dropdownlist ,and i want to catch the event when user changes his selection
    When I use the mouse,I succeed to catch the "change" event,but when i use the keyboard ,the "change" event does not fire (the auto complete of the dropdown works),How can I catch this event or any other event for changing dropdown selection with keyboard
    ?
    I attached my code below.
    Thanks in advance.



    html code:
     <input id="identificationTypes" name="identificationTypes" requiredidtype />

    script code:

      $("#identificationTypes").kendoDropDownList({
                index: 0,
                optionLabel: "-------please choose------",
                dataTextField: "Value",
                dataValueField: "Key",
                filter: "contains",
                change: onChange,
                dataSource: {
                    type: "json",
                    pageSize: 20,
                    transport: {
                        read: "../ContactDetails/GetIdentificationTypes"
                    }
                }
            });

    function onChange() {
    alert('bla');
    }
  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 08 Nov 2012 Link to this post

    Hello Yaron,

    Basically the change event is triggered when you "blur" (loose focus) or press "enter".

    As a work-around you could attach a handler to the keydown event like this one:
    $('#DropDownID').closest('.k-dropdown.k-widget').keydown(function(e){
        var theValue = $('#DropDownID').data().kendoDropDownList.value();
       console.log(theValue );
    })

    I hope this helps.

    Kind regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Mikkel
    Mikkel avatar
    58 posts
    Member since:
    Aug 2012

    Posted 02 Jun 2015 in reply to Petur Subev Link to this post

    Is this still the case? Is there no other way to trigger the change event when the value is changed using the keyboard.

    Seems a little weird to fire onchange event only on blur...

  5. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2564 posts

    Posted 05 Jun 2015 Link to this post

    Hi Mikkel,

    Te change event is triggered when you "blur" (loose focus) or press "enter". So if you want to trigger it in any other circumstance you will need to do it manually.

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready