I want to verify if Shift or Ctrl key is pressed to make my own multiselection.
I use a digitizer to draw polygon, rectangle, etc… to make selection from geometry on server-side (with mapguide api).
My problem is when I want to make a multiselection, I need to press Shift or Ctrl key and draw my rectangle for example. After I send to the server my rectangle geometry and that I'm in multiselection because of Ctrl or shift key pressed.
But when I press shift and I want to draw, I see my pointer of drawing but on first click, my draw stop.
And when I press Ctrl and I want to draw, I see my pointer of drawing too but when I click, nothing happend.
I have disable map interactions :
me._map = new ol.Map({
interactions: ol.interaction.defaults({
doubleClickZoom: false,
shiftDragZoom: false,
altShiftDragRotate: false,
keyboard: false,
pinchRotate: false,
pinchZoom: false,
}),
controls: [],
layers: [layer],
target: me._options.target,
view: new ol.View(options)
});
I want to do this since I'm drawing with my digitizer:
on(document, "keydown", function (event)
{
if (event.keyCode == keys.SHIFT || event.keycode == keys.CTRL)
me._isShiftDown = true;
});
on(document, "keyup", function (event)
{
if (event.keyCode == keys.SHIFT || event.keycode == keys.CTRL)
me._isShiftDown = false;
});
window.onblur = function ()
{
me._isShiftDown = false;
};
Best Answer
I had a similar requirement, so I managed to solve it that way: