So, we have a web application which displays a bunch of documents to the user. The page that we display to the user has a bunch of Frames, IFrames and DIVS. Maybe around 6-7 of them. We are providing support for keyboard based navigation; ie; if user presses up, we move to next document, down for previous document, Pgup for next page, PgDown for previous page, and so on. There are about 10 differrent keys that we need to handle. The keyboard handlers are spread out all over. 4 othem in one frame, 2 of them in another DIV, and so on. It's a mess.
Now, what happens is that the frame that has the focus gets all the keyboard input, and sometimes the application becomes unresponsive to keyboard input (our keyboard handlers don't get called). We have to make the user click on a frame, so that the frame gets the focus, and then press keyboard, which is silly, because the idea behind keyboard navigation is that user doesn't have to use the mouse.
So, is there any way I can centeralize all my keyboard handling. It would be much easier to maintain if all keyboard handling was in one place, but we need to make sure that no matter which frame has focus, the centeralized keyboard handler gets called.
The only thing that I think of is to make each frame implement keyboard handling. Every frame should bubble up the event to it's parent, which will bubble the event upto it's parent, until we reach grand-daddy of all frames, that can handle all keyboard events and call the appropriate functions on the child frames based on the business logic. But, in this soultion we will have to change the code in each and every frame. That's a nightmare, which is compunded by the fact that each frame individually loads differrent
jsp pages. So, I have to add the bubbling code to maybe 15-20 jsp's. Does someone have a better solution? We don't mind implementing hacks for now, even *flame retardent suit on* IE hacks. We are getting close to release, and we will have time to put a robust solution for the next release. We need to refactor that page for performance reasons, anyways. So, any suggestions for hacky and/or robust soultions are appreciated.