I've come across an issue regarding the keypress event sequence in Firefox and IE. In Firefox, pressing a key on a focused input writes the character first before firing the event function. On the other hand, IE does it in the opposite order.
My specific problem is having two input text fields side by side where I want the second one to gain focus immediately after typing a single character in the first field. This behaves as expected in Firefox but not in IE since it switches focus before the character appears in the first field...
Below is a simplified version of the code I'm currently using (both elements are text inputs):
var one = document.getElementById('one');
var two = document.getElementById('two');
one.addEventListener('keypress', function(e) {
e.target.nextElementSibling.focus();
});
How can this be resolved? Is there a way to ensure that focus is switched only after the pressed key registers on the screen?