I have to support a data entry form, coded by someone long gone, that is using Javascript to make the Enter Key behave like the Tab key, so that people entering their data can type -, - etc. very quickly. It is set up this way because they have to enter 3 numbers for each day of a month, one month per form submission, and they usually wait until they have a whole month's worth of data to do it.
Here is the JS function that is overriding the Enter key:
function handleEnter(field, event) {
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
if (keyCode == 13) {
var i;
for (i = 0; i < field.form.elements.length; i++)
if (field == field.form.elements[i])
break;
i = (i + 1) % field.form.elements.length;
field.form.elements[i].focus();
return false;
} else {
return true;
}
}
This is actually working fine for everyone, in every browser I have tested, except for one customer, who has to enter data for several locations each month. Last week, the Enter key stopped working at all for her on this form. What's more, now she can't even click in the third column of each day, or go to the last day of each month's row. I have watched this problem on screen sharing, but I am not able to control her computer or debug the JS remotely. (The Tab key does move her cursor, but to random fields--even though all the tabindex values are set correctly.)
I cannot recreate this issue on any computer. She says she has been using the same setup (Win XP / IE 8) for six months, and the problem just started. I have tried in a variety of combinations of browsers/OS's, including two Win XP machines running IE 8. (A strange side note: she said she also cannot click on the third field when using her iPad on the form, but of course, my iPad works fine with it.)
I saw this question on StackOverflow which seemed related, except I am not trying to change the keystroke, just intercept it, prevent the default behavior, and do some other behavior: How do I convert Enter to Tab (with focus change) in IE9? It worked in IE8
I thought that maybe she had some malware/keylogger on her computer that was causing this problem, but the problem with the iPad calls that into question. Could she have malware in her router? I have to get this working for her again, but I can't recreate this issue to debug it.
Has anyone ever seen anything like this before?