document.activeElement === myElement
Use the speechSynthesis API.
speechSynthesis
You don't need dotenv anymore since Node 20.6.