[OpenLayers-Users] Detect if key pressed during click

soatley shawn at niagarafalls.ca
Mon Jun 15 15:54:42 EDT 2009


I have a custom handler for my click event that is my default click handler
to retrieve information from my WMS server:

OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
    defaultHandlerOptions: {
        'single': true,
        'double': false,
        'pixelTolerance': 0,
        'stopSingle': false,
        'stopDouble': false
    },

    initialize: function(options) {
        this.handlerOptions = OpenLayers.Util.extend(
                        {}, this.defaultHandlerOptions
                    );
        OpenLayers.Control.prototype.initialize.apply(
                        this, arguments
                    );
        this.handler = new OpenLayers.Handler.Click(
                        this, {
                            'click': this.onClick
                        }, this.handlerOptions
                    );
    },

    onClick: function(e) {
        /* do standard click function: query WMS, get feature, do popup,etc.
*/
    }
});



How can I tell if someone was pressing the control key at the same time?  I
saw some keyMask information and wasn't sure if I had to setup a different
Click Handler in order to get it to work.

The purpose for this is to determine whether someone wants to select
multiple items (properties, roads, etc.) or not.  If the user is selecting a
single item (CTRL not pressed) then query the WMS server, show the popup and
create the feature.  If the user is selecting multiple items (CTRL is
pressed) then query the WMS server and highlight the property and show the
list of selected items in another window.  I can create my own code to do
all the WMS /feature/window stuff, just need some assistance detecting the
CTRL with the click and sending it to a different function.

Thanks!
Shawn

-- 
View this message in context: http://n2.nabble.com/Detect-if-key-pressed-during-click-tp3082415p3082415.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list