Click here to Skip to main content
15,945,939 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 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) {
                    window.event.keyCode = 9;
                    return false;

The following line of code does not work:

window.event.keyCode = 9;
Updated 20-May-22 2:05am

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