0

I can't figure out how to make enter key work instead of tab key to navigate between fields in form view in odoo v8,i have followed this post already https://www.odoo.com/forum/help-1/question/how-to-make-the-enter-key-work-as-tab-key-1310

But the code mentioned in this post works only for tree editable view .

  • Either on enter key you give logic of tab(switching between two fields) or else you can do one thing. Use **event.preventDefault()** and then pass the ascii value of **TAB** key when enter key is pressed. – Keval Mehta Jun 20 '18 at 06:11
  • @Keval Mehta how can i do that ? – Ahmed Tarek Jun 20 '18 at 16:36

2 Answers2

0

This is reference code in JS for your needs to focus next using enter.

Modify it as you wanted it.

window.onkeypress = function(e) {
    if (e.which == 13) {
        e.preventDefault();
        var inputs = document.getElementsByClassName('input');
        for (var k = 0; k < inputs.length; k++) {
        if (document.activeElement.id == inputs[k].id && k+1 < inputs.length ) {
            inputs[k+1].focus();
            break;   
        }
    }
0

I solved it !

Here is the link and of course credits are mentioned in the repository