There is a <input type="text"> . The problem is that after triggering keyboard events (say Enter key, or another character key) and then immediately click (Touchpad) on input, the event loop does not catch mouse events. Starts to catch after a delay of ~ 800 ms.

 var el = document.getElementById('keyboard'); var prevTime = new Date().getTime(); el.addEventListener('keyup', () => { console.log('keyup'); var curTime = new Date().getTime(); console.log(curTime - prevTime); prevTime = curTime; }, false); el.addEventListener('mousedown', () => { console.log('mousedown'); var curTime = new Date().getTime(); console.log(curTime - prevTime); prevTime = curTime; }, false); 
 <input type="text" id="keyboard"> 

enter image description here

Interesting moments, the delay occurs only character keys and only on the Touchpad.

OS: Windows 10,
Chrome: 68.0.3440

Why can the event loop not immediately catch the event?

  • In the above example, all events are caught - Anton Shchyrov
  • @AntonShchyrov slightly updated the question. The bottom line is that if you press the character key, and then very quickly click the mouse, the event is not caught (windows). - Kostiantyn Okhotnyk
  • one
    js just dutifully forwards system events of the keyboard and mouse, and it is unlikely that they can be influenced somehow, except by picking the touchpad settings - andreymal
  • one
    It is possible to delay the response to the default touch. True, it’s 300ms, not 800. Here’s how you can remove it from stackoverflow.com/questions/12238587/… - Dmytryk
  • one
    Maybe the point needs to adjust the settings of the control panel? - June Matthews

1 answer 1

You see that in the example in question there is no delay. We have to guess what you have not shown? You are welcome:

Enter key

The delay is caused by sending the form and reloading the page.

  • Thanks for the answer, but in the current example, the delay is not only on the Enter key. On any character key. - Kostiantyn Okhotnyk
  • @KonstantinOkhotnick I'm on Windows 10, Chrome 68.0.3440.106. - Igor
  • It turned out that only on the touchpad is played - Kostiantyn Okhotnyk