[ka-Map-users] Customize key press on viewport

David Badke dbadke at uvic.ca
Tue May 16 16:35:32 EDT 2006


I wanted to handle arbitrary key press events when the navigator tool is 
active. I originally added a case to the kaTool.onkeypress function, but 
I didn't like changing the core code like that. So I've come up with 
another way, which I am hoping the illustrious ka-Map crew will accept 
in the cvs.

1. Change kaTool.onkeypress function 'default' case from:

          default:
              b = false;
 
to:
          default:
             b = false;
             if (this.userKeyPress)
                  b = this.userKeyPress(charCode);

2. If you want to add key press handling, after the navigator tool is 
initialized (startUp.js), add:

         myKaNavigator.userKeyPress = myKeyPress;

where myKeyPress is something like:

         function myKeyPress(charCode) {
           result = true;
           switch (charCode) {
             case nn:
               ... whatever ...
               break;
           
             default:
               result = false;
           }
           return result;
         }

If myKaNavigator.userKeyPress is not set, nothing happens, same as before.


Comments? Better ways to do this?

David




More information about the ka-Map-users mailing list