This is a migrated thread and some comments may be shown as answers.

How to detect keypress 'Enter'?

1 Answer 1047 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Garling
Top achievements
Rank 1
Garling asked on 14 Jan 2015, 11:57 PM
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".






1 Answer, 1 is accepted

Sort by
0
Accepted
Tsvetina
Telerik team
answered on 19 Jan 2015, 12:51 PM
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.

 
Tags
General Discussion
Asked by
Garling
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or