Change keyboard shortcut for page up and page down in Evince

I would like to change the keyboard shortcuts for "Previous Page" and "Next Page" in evince. I have a Dell Vostro 5568 laptop where the PgUp and the PgDn keys are located awkwardly up to the right on the keyboard. Instead I would like to use Ctrl+Left and Ctrl+Right (currently bound to "Rotate Left" and "Rotate Right"), or alternatively to use Ctrl+Up and Ctrl+Down.

From the Gnome Help page I figured I had to use dconf-editor. Here are two screenshots showing my settings:

enter image description here enter image description here

Now when I click "Go" menu in Evince, and move the mouse pointer down to menu item "Previous Page", I should be able to enter a new keyboard shortcut. But if I press Ctrl+Up and close Evince and reopens it, the shortcut does not work. Here is a screenshot from Evince:

enter image description here

I am using Ubuntu 16.10. There is also an older question for Ubuntu 10.10 here.


Solution 1:

Firstly, just in case you don't know, you can use Space and Shift-Space instead of PgDn and PgUp.

If you still want to change the keybindings, then unfortunately I think that for evince the keybindings are hard-coded. Three possible solutions are:

  1. Switch to atril which is the MATE fork of evince and which allows the customisation of keybindings, at least via an accels file (at ~/.config/atril/accels). For comparison, you could look at, say, ~/.config/nautilus/accels.

  2. Use something with AutoHotkey functionality (for some possibilities, see this stackexchange question).

  3. (If you're feeling adventurous) patch the source of evince and recompile:

To get the source used by Ubuntu:

apt-get source evince

If this doesn't work, uncomment the deb-src lines in /etc/apt/sources.list.

The offending lines, responsible for the bindings in evince are:

add_scroll_binding_keypad (binding_set, GDK_KEY_Page_Up, 0, GTK_SCROLL_PAGE_BACKWARD, GTK_ORIENTATION_VERTICAL);
add_scroll_binding_keypad (binding_set, GDK_KEY_Page_Down, 0, GTK_SCROLL_PAGE_FORWARD, GTK_ORIENTATION_VERTICAL);

in shell/ev-view.c. (See here on GitHub. GitHub link provided for convenience, but preferably don't get the source from there, but via apt-get as described above.)

The lines need to be changed to:

add_scroll_binding_keypad (binding_set, GDK_KEY_Up, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_BACKWARD, GTK_ORIENTATION_VERTICAL);
add_scroll_binding_keypad (binding_set, GDK_KEY_Down, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_FORWARD, GTK_ORIENTATION_VERTICAL);

Note, however, that you won't get security fixes to evince automatically if you compile it yourself.

For reference, if somebody wishes to modify other keyboard shortcuts in evince, some of the action (as opposed to motion) bindings are specified in shell/ev-application.c in the definition of const gchar *action_accels[] (here on GitHub).