matplotlib: How to pick up shift click on figure?
You can also bind a key press and key release events and do something like:
self.fig.canvas.mpl_connect('key_press_event', self.on_key_press)
self.fig.canvas.mpl_connect('key_release_event', self.on_key_release)
...
def on_key_press(self, event):
if event.key == 'shift':
self.shift_is_held = True
def on_key_release(self, event):
if event.key == 'shift':
self.shift_is_held = False
Then you can check in your onClick
function if self.shift_is_held
.
if event.button == 3:
if self.shift_is_held:
do_something()
else:
do_something_else()