- // If zoomed-out and in single page mode, switch pages with PgUp/PgDn.
- if (!ui.view_continuous &&
- (0.96 * ui.zoom * ui.cur_page->height <
- GTK_WIDGET(canvas)->allocation.height)) {
- if (event->keyval == GDK_Page_Down) {
+ /* In single page mode, switch pages with PgUp/PgDn (or Up/Dn)
+ when there's nowhere else to go. */
+ pgheight = GTK_WIDGET(canvas)->allocation.height;
+ adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(GET_COMPONENT("scrolledwindowMain")));
+
+ if (event->keyval == GDK_Page_Down || event->keyval == GDK_Down) {
+ if (!ui.view_continuous &&
+ (0.96 * ui.zoom * ui.cur_page->height < pgheight ||
+ adj->value == adj->upper-pgheight))
+ {