How to detect keypress 'Enter'?

2 posts, 1 answers
  1. Garling
    Garling avatar
    8 posts
    Member since:
    May 2014

    Posted 14 Jan 2015 Link to this post

    I have a modalview with two data-bind buttons, "click: enter" and "click: close". I also have a textbox data-bind "value: BtscannedCust". 

    In my js file:

    window.BTscanView = kendo.observable({
            
            
            enter: function () {
                var that = this;
                customerScanDataSource.add({ scanned: this.BtscannedCust });
                customerScanDataSource.one("sync");
                customerScanDataSource.sync();
                document.getElementById("BtscannedCust").value = "";
                var text_input = document.getElementById("BtscannedCust");
                text_input.focus();
                text_input.select();
                
                console.info("Test");

            },        

            close: function () {
                $("#Btscan").data("kendoMobileModalView").close();
                this.BtscannedCust = "";
            }       
        });

    I need to detect a 'Enter" keypress in the textbox and then fire the "enter: function".






  2. Answer
    Tsvetina
    Admin
    Tsvetina avatar
    1875 posts

    Posted 19 Jan 2015 Link to this post

    Hello Garling,

    Have you tried using the keypress event as suggested in this Stack Overflow thread?
    How to detect enter key

    I tested it on a device on my side and it worked as expected. Here is how I defined the input on my side:
    <input data-bind="events: {keypress: enter}" />


    Regards,
    Tsvetina
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
Back to Top