Keydown on div?

There was a need to attach a handler and normally respond to focus events for unfocused elements (such as keydown on div).

Of course, the usual clique no focus will not fall.

I even started to write my EventManager (with preference and senorita) c alternative mechanism of focus, which will be bindit your handler to body, and from there to run your event. But in the process of implementation began to experience some problems, in performance of decisions which I am not sure, afraid of the strong brakes (though haven't checked).

In global terms this thing while it is necessary to use only one widget (which can be multiple on the page), but it is unknown what will happen next.

Actually, in the end, the question two.
1. Are there regular ways to force the browser to set focus to the desired elements and pull them on such events? You want cross-browser compatibility at least at the level IE9+ (but it's better 8+).
And, in the case of a positive response
2. Whether to use one of these methods, or better to finish and use your EventManager?
October 3rd 19 at 04:14
3 answers
October 3rd 19 at 04:16
here I propose to add tabindex="0" to get focus.
About the cross-browser capability — not tested.
Cool. Everything works down to IE7.
It is a pity, will have to produce these tabindex.
Only in Firefox the bug is observed. If you make two items with students, when focus is on a Tab from the first to the second work out for the first keydown, focus goes to the second and then for it fulfills the same keydown. - lizzie.Grah commented on October 3rd 19 at 04:19
October 3rd 19 at 04:18
Once faced with this same problem. The simplest solution was to use A c tag is display:block instead of the DIV.
October 3rd 19 at 04:20
In the spirit of the question is understood, You need to look at the google closure library. It nicely solved both issues + there are hundreds of advantages. She and ExtJS does the class layer in front of the DOM that makes it easy to solve similar and more complex problems.
Briefly visited the library – cool. Will definitely use in the next project. This, unfortunately, will not work, as much has already been written. Under jQuery.
And connect to solve my problems the second library is how to connect jQuery to twice use function $. - lizzie.Grah commented on October 3rd 19 at 04:23

Find more questions by tags HTMLJavaScript