> From: Yehuda Katz > > I need to create a basic keyboard for a touchscreen app that > will be in the page. There might be multiple text boxes on > one page, and I need a way to keep the JS knowing which box > actually "has focus" (even though the keys pressed on the > keyboard will actually have focus in the JS sense). > > I could keep a global variable with the details, but is there > a better way?
If a touch key steals the keyboard focus, won't the input field lose its blinking cursor and the touch key gain a dotted focus rectangle? That doesn't sound like expected behavior from a touch keyboard. It would be better to leave the keyboard focus alone. Instead of button or A elements or the like, make your own button object that uses a div and responds to mouse events itself to handle clicks and show its hover/up/down state. This way you won't steal the focus. For efficiency, I suggest attaching your event handlers to the container div that holds all the keys, then do your own hit-testing on event.clientX/Y to determine which key the event was in. To get started, you could do it the easy way and attach the events to each div, but that's a lot of event handlers. You may still need that global variable to keep track of which element actually *has* the focus - is there a window or document property/method to find out which element currently has the focus, or do you have to watch the focus and blur events? -Mike _______________________________________________ jQuery mailing list [email protected] http://jquery.com/discuss/
