[ka-Map-users] OnKeyUp and OnKeyDown tool selector

Pedro Garcia pedro.gspace at gmail.com
Thu May 18 15:37:35 EDT 2006


Hey guys,

I saw a recent post about key handlers, and I
have 2 questions about this subject.

1st) The keys are not captured in initial stage,
when the page is loaded at first time. I suppose
it happens when the viewport is not focused. This
is a bug? I think it's useful for the user if the
keys are "usable" even if the view port is focused,
something like a "global" hotkey.

2nd) I'm trying to develop a function to improove
the navigability. Based on Photoshop and CorelDraw,
the idea is allow user select different tools
by pressing CTRL, ALT, SHIFT, and combinations
of these keys. For example, considering the pan
the standard tool, the application opens with
pan tool selected, and if the user press AND HOLD
(keydown event) the SHIFT key, the tool (and mouse
pointer) change to the query tool. When the user
release the key (keyup event), the tool back to
the pan tool (and mouse pointer too).

The problem is that kaTool.prototype.onkeypress
handler is not called when you press CTRL, ALT or
SHIFT keys.

I'm working overriding the onkeydown and onkeyup
of document object, so the keys are capture even
if the viewport isn't focused. I'm in the right
way? There is a better solution?

I call this function in the onload event of
the BODY tag of index.html:
function loadEventHandlers() {
  document.onkeydown = event_OnKeyDown;
  document.onkeyup = event_OnKeyUp;
}


And the event handlers are something like this:
event_OnKeyDown = function(e) {
  e = (e)? e : ( (event)? event : null );
  if (e) {
    // Process the key here
  }
}
regards,

===========================================
  Pedro Simonetti Garcia
===========================================
  Software Engineering
  Hiparc Geoteclogogia ( www.hiparc.com.br)
===========================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/ka-map-users/attachments/20060518/3a6de11c/attachment.html


More information about the ka-Map-users mailing list