WHEN AN OBJECT IS AT THE FOCUS code example
Example 1: set focus javascript
document.getElementById("ThingToSetFocusOn").focus();
Example 2: Javascript find element with focus
var currentElementWithFocus=document.activeElement;
document.getElementById("ThingToSetFocusOn").focus();
var currentElementWithFocus=document.activeElement;