Detect Cursor in Browser Form Field?

Hey gang. I'd like to set up a hot-key-triggered macro to close a broswer tab. Does anyone know a way that I could detect if the cursor is in a text-entry form field? Thanks for any help you can provide!

Hey @devoy ,

There's no easy way to detect that a text field has focus on macOS.

In a browser you might be able to do this with some JavaScript.

-Chris

Can you provide an example?
Close immediately? after certain event(s)?