[GIS] OpenLayers 3 capturing various click events

eventsopenlayers

I would like my KML layer in OpenLayers 3 (OL3) to respond to different types of click events.

I have a single click method working nicely. But how do I get it working for "shift-clicks" "double clicks" etc?

 map.on('singleclick', function(evt) {                         
   var feature = map.forEachFeatureAtPixel(evt.pixel,
     function(feature, layer) {
     // do stuff here with feature
     return [feature, layer];                                  
   });                                                         
 });                                                           

This was a good start, but I can't quite put the OL3 API documentation together.

Best Answer

ah ok dblclick is the answer

// set mode to current mode of double clicked feature                       
map.on('dblclick', function(evt) {
  console.log('doubled');
  var feature = map.forEachFeatureAtPixel(evt.pixel,
    function(feature, layer) {
      // do stuff here
    });
});                                                                    

and evt.originalEvent.altKey, evt.originalEvent.ctrlKey, evt.originalEvent.metaKey, evt.originalEvent.shitKey are all availabe within the handler!