Is there a way in Javascript to determine if no elements are in focus? -


i'm building hotkeys page of html:

   $(document).bind('keypress', function (e) {         var event = (e.keycode ? e.keycode : e.which);          if (event == letter_p) {             // go page         }     } 

but problem if entering text on page (in textbox element, etc) , hit letter 'p', off page. want redirection happen if not in elements.

document.activeelement supported major browsers these days. if no element in focus activeelement return document body, so:

if (document.activeelement === document.body) {     // nothing in focus } 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -