Click here to Skip to main content
15,889,853 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 because the enter keypress doesn't submit the form..although I couldn't change the keycode to 9 as when I press 'tab' nothing happens:

What I have tried:

<pre lang="Javascript">
     
$(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;
Posted
Updated 20-May-22 2:05am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900