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

Keypress event on custom editor

1 Answer 1924 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Luis
Top achievements
Rank 1
Luis asked on 28 Apr 2014, 11:52 PM
Hello Telerik,

I want to handle the "enter" key while keyboard navigation is enabled.

I could handle the keydown event within the tbody.

I need to handle a keypress event in a custom editor too. And here comes the trouble.. I registered a keypress event in the custom editor but is never fired with the "enter" key. The other keys like letters and numbers fire the event.

I could reproduce my code logic here:
http://trykendoui.telerik.com/onaD

am I missing something? My requirement is to handle keydown => keypress => and keyup in the editor.
The keydown and keyup is firing ok. 

Can you help me?

Thank you in advance, 

regards

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 30 Apr 2014, 03:15 PM
Hi Luis,

Basically the "keypress" event is not fired as it executed after the "keydown" event (used by the Grid) and only if there is a character resulting from it. For more information on the matter you can check the following StackOverflow post:

I would suggest to use the global "keydown" handler to execute your custom code:

$("#grid table").on("keydown", function (e) {
        //if current key is Enter
        console.log(this);
        if (e.keyCode == 13) {
            //prevent keydown
            e.stopImmediatePropagation();
            var grid = $("#Employees").data("kendoGrid");
            var currentCell = grid.current();

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Luis
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or