navigation toolbar keyboard shortcuts patch

Hi,

I'm a big fan of keyboard shortcuts, so I decided to add these guys to
lib/matplotlib/backend_bases.py

I'm not sure if this is too much, and maybe these should be configurable
down the line, but here's my first stab at it, what do you all think?

in the same order as they appear in the toolbar:
'h' or 'r' for Home/Reset
left arrow or 'z' or backspace for Back
right arrow and 'x' for Forward
'p' for pan axes with right, zoom with left mode toggle
'o' for z*o*om to rectangle mode toggle
's' for save

'z' and 'x' I borrowed from the Opera browser, very handy to for
righties who can have their left hand on the keyboard while using the mouse.

I decided to use 'o' for zoom to rect since it's located right next to
the 'p' for panning, and both are modes.

There was also a message on the matplotlib-users list in July that this
patch would be useful for
Subj: [Matplotlib-users] tool bar help / feature request

(but I don't know how to reply to that message as I was not on the the
users list at that time)

cheers,
Paul Ivanov

keyboard_navigation.diff (1.1 KB)

···

From: Ben Axelrod <baxelrod@...653...> - 2008-07-31 16:08

Paul Ivanov schrieb:

Hi,

I'm a big fan of keyboard shortcuts, so I decided to add these guys to
lib/matplotlib/backend_bases.py

I'm not sure if this is too much, and maybe these should be configurable
down the line, but here's my first stab at it, what do you all think?

in the same order as they appear in the toolbar:
'h' or 'r' for Home/Reset
left arrow or 'z' or backspace for Back
right arrow and 'x' for Forward
'p' for pan axes with right, zoom with left mode toggle
'o' for z*o*om to rectangle mode toggle
's' for save
  

I like this idea very much. What I would like to see is panning associated with the space bar, like it's done in Adobe Acrobat: panning is only activated _while_ you press space. I think this is more difficult to implement. Once I had a quick look at it and abandonded this project, it was too complicated for me. Perhaps you can manage this?

'z' and 'x' I borrowed from the Opera browser, very handy to for
righties who can have their left hand on the keyboard while using the mouse.
  

On german keyboards y and z are exchanged. Having these keys configurable would be handy.

Gregor

Hi Paul,

I'm amenable to additional keys, but check out
http://matplotlib.sourceforge.net/users/navigation_toolbar.html which
details which keys are already in play. Also, with your patch, please
submit a patch against the navigation toolbar doc
doc/users/navigation_toolbar.rst . Maybe a ReST table that details all
of the key bindings?

Thanks,
JDH

···

On Thu, Oct 16, 2008 at 9:18 PM, Paul Ivanov <pivanov314@...149...> wrote:

Hi,

I'm a big fan of keyboard shortcuts, so I decided to add these guys to
lib/matplotlib/backend_bases.py

I'm not sure if this is too much, and maybe these should be configurable
down the line, but here's my first stab at it, what do you all think?

in the same order as they appear in the toolbar:
'h' or 'r' for Home/Reset
left arrow or 'z' or backspace for Back
right arrow and 'x' for Forward
'p' for pan axes with right, zoom with left mode toggle
'o' for z*o*om to rectangle mode toggle
's' for save

'z' and 'x' I borrowed from the Opera browser, very handy to for
righties who can have their left hand on the keyboard while using the mouse.

Here's an updated patch:

I decided to go with 'c' and 'v' for Back and Forward since these keys
are in the same place on most localized keyboard layouts (sorry, dvorak
users) (as JDH pointed out, I could not use 'z' and 'x' because 'x' is
used as a modifier in Pan/Zoom mode)

I've added a ReST table detailing all of the key bindings as per JDH's
suggestion.

I included 'g' and 'l' for toggling grid and y scale under the heading
of "In axes only" though there's probably a better way of saying that.

Not sure if those belong there, but they seem to have not been
documented elsewhere ( same with 'f' for fullscreen)

navigation_toolbar.rst compiled and looked fine with rst2html.py and
rst2newlatex.py. The bullets ('- ') created extra vertical whitespace in
the table when I ran latex on the rst2latex.py output. If that's a
problem, those can be replaced with '-- '

looking forward to your feedback,
Paul Ivanov

John Hunter, on 2008-10-17 04:02, wrote:

keyboard_navigation.diff (2.66 KB)

···

On Thu, Oct 16, 2008 at 9:18 PM, Paul Ivanov <pivanov314@...149...> wrote:

Hi,

I'm a big fan of keyboard shortcuts, so I decided to add these guys to
lib/matplotlib/backend_bases.py

I'm not sure if this is too much, and maybe these should be configurable
down the line, but here's my first stab at it, what do you all think?

in the same order as they appear in the toolbar:
'h' or 'r' for Home/Reset
left arrow or 'z' or backspace for Back
right arrow and 'x' for Forward
'p' for pan axes with right, zoom with left mode toggle
'o' for z*o*om to rectangle mode toggle
's' for save

'z' and 'x' I borrowed from the Opera browser, very handy to for
righties who can have their left hand on the keyboard while using the mouse.

Hi Paul,

I'm amenable to additional keys, but check out
http://matplotlib.sourceforge.net/users/navigation_toolbar.html which
details which keys are already in play. Also, with your patch, please
submit a patch against the navigation toolbar doc
doc/users/navigation_toolbar.rst . Maybe a ReST table that details all
of the key bindings?

Thanks,
JDH

Thanks Paul, for the enhancements, and especially for doing the extra
work to document the functionality and test the docs. Applied to svn
6291. If you are inclined, we probably need an rc param or something
like that to determine which keys mpl responds to since, as we have
more of these, we increase the risk that we get in the way of
application developers embedding mpl.

Eg, in matplotlibrc, one could do

  toolbar.keys : x, y, c, v, g, f, p, z, control, left, right # with
docs describing what key does what

So the user could turn off any or all of these. Then in
backend_bases, before we issue an event based on a key stroke, we
could check this default list to make sure the user wants mpl handling
these events.

JDH

···

On Tue, Oct 21, 2008 at 8:57 PM, Paul Ivanov <pivanov314@...149...> wrote:

Here's an updated patch:

I decided to go with 'c' and 'v' for Back and Forward since these keys
are in the same place on most localized keyboard layouts (sorry, dvorak
users) (as JDH pointed out, I could not use 'z' and 'x' because 'x' is
used as a modifier in Pan/Zoom mode)

I've added a ReST table detailing all of the key bindings as per JDH's
suggestion.