[ka-Map-users] OnKeyUp and OnKeyDown tool selector
David Badke
dbadke at uvic.ca
Tue May 23 14:13:09 EDT 2006
I also tried to do this, with no success. It appears that Javascript is
not handling the modifier key (shift, control, etc.) "down" events, or
not passing them on. I haven't had time to dig further, but it does seem
that the events simply are not triggered. I was also trying to find a
way to get the state of the shift, control, etc. keys in the mouse down
event (which I have done with other programming languages), but could
not find any way to do it in Javascript.
David
Pedro Garcia wrote:
>
> 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,
--
David Badke
Humanities Computing and Media Center
University of Victoria, BC, Canada
More information about the ka-Map-users
mailing list