0

I'm using the javascript focus() function to automatically jump from one input block to the next. Unfortunately, on mobile chrome every time you call the focus() function chrome decides to flicker or twitch to refocus to the next block. Is there any way to stop the default refocusing/scrolling behavior when focus() is called? Here's a 10 second video of my problem on mobile chrome. https://youtu.be/UmHJVxqrLS8

I would think this would work but it doesn't.

code[i + 1].focus({preventScroll: true});

These answers didn't really help me either Preventing page from scrolling on focus switching

Joshua Segal
  • 541
  • 1
  • 7
  • 19

1 Answers1

0

Check this out, am sure it will help you.

https://codepen.io/wesleypimentel/pen/KpgXJW?editors=0010

function keydown(e) {
for (var i = keys.length; i--;) {
    if (e.keyCode === keys[i]) {
        preventDefault(e);
        return;
    }
}

}

Eshjay
  • 1
  • 1