I'm trying to detect if focus event was triggered by user (manually).
When it comes to the click
event, it is possible to check if event.originalEvent
is present inside handler method:
typeof event.originalEvent != "undefined"
Unfortunately, it behaves different for focus event. Please check the example.
Try to click on the first <input>
and then click on "trigger click" button for the second input, you will see click undefined
, what means that the event.originalEvent
is not present.
Then try to click on the first <input>
followed by the click on "trigger focus" button for the second input, you will see focus object
, event.originalEvent
is present this time.
- How to detect if focus event was triggered by user (not programmatically)?