hasFocus

The hasFocus() method of the Document interface returns a boolean value indicating whether the document or any element inside the document has focus.

MDN Reference