'Changing the default of the enter key to tab in asp.net mvc

I am trying to change the enter key to tab in asp.net mvc.

Whenever I pressed 'Enter', the page refreshed so I used the following code and it does work mostly although I couldn't change the keycode to 9:

   $(document).on("keypress", 'form', function (e) {
            var code = e.keyCode || e.which;
            if (code == 13) {
                
                e.preventDefault();
                window.event.keyCode = 9;
                return false;
            }
        });

The following line of code does not work:

        window.event.keyCode = 9;


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source