22

Is it possible to determine whether the Shift key is pressed during a mousedown d3.event? if possible could show me a way to do this, try looking in the API, but could not find something useful

Cristian G
  • 779
  • 2
  • 10
  • 21

2 Answers2

33

You should be able to use something like this:

d3.select(window).on("click", function() {
    if (d3.event.shiftKey) {
        alert("Mouse+Shift pressed");
    }
});

Demo: http://jsfiddle.net/SO_AMK/NTGKG/1/

A.M.K
  • 16,727
  • 4
  • 32
  • 64
2

Maybe it is necessary to use:

if (d3.event.sourceEvent.shiftKey) {
  console.log("shift pressed");
}
ReHa
  • 71
  • 6