How would I find if a textbox (or textarea) currently is in focus? I don\'t care to know which one it is, I just need to know if one is in focus (has the cursor in it). How
Extending the accepted answer by a check for editable HTMLDivElements:
if (document.activeElement.nodeName == 'TEXTAREA' || document.activeElement.nodeName == 'INPUT' || (document.activeElement.nodeName == 'DIV' && document.activeElement.isContentEditable)) { // … }