#183 Make shift+space scroll *up*


In most web browsers, [space] means the same as [page down] and [shift]+[space] means the same as [page up]. This is useful since [space] and [shift] keys are nice and big, and they're in the same place on all keyboards (unlike page up/down!). In WinDjView [space] works as expected (thanks!), but [shift]+[space] scrolls *down*. When skimming over dense mathematical text, you can go surprisingly far the wrong way before you realise it!

This request is simple: please change [shift]+[space] to page *up* instead of down. At the very least make it do nothing, so I don't accidentally scroll the wrong way then have to find where I was! Perhaps a silly request but this habit is well ingrained in me.


  • Jim

    To make things a little easier I looked at what code would need to change for this. It's pretty straightforward, although I couldn't test it since the project doesn't compile in my computer's version of Visual Studio.

    The quick summary is: check whether the shift key is down by checking whether GetKeyState(VK_SHIFT) is non-zero. It is important to use GetKeyState and NOT GetAsyncKeyState because if CPU load is high then the key state may have changed (i.e. the shift key released) since the space key message was queued. Technically the return value of GetKeyState is more complicated than a boolean, but this isn't important for keys that don't toggle (unlike Caps Lock, Scroll Lock, Num Lock).

    In more practical terms: In DjVuView.cpp, in the switch statement in CDjVuView::OnKeyDown, replace the current code for the VK_NEXT, VK_SPACE, VK_PRIOR and VK_BACK cases (currently in two groups) with:

    case VK_NEXT:
    case VK_SPACE:
    case VK_PRIOR:
    case VK_BACK:
        if ((nChar == VK_NEXT) || ((nChar == VK_SPACE) && !GetKeyState(VK_SHIFT)))
            szScroll.cy = m_szPage.cy;
            bNextPage = true;
            bAlignTop = true;
            szScroll.cy = -m_szPage.cy;
            bPrevPage = true;
            bAlignBottom = true;
    Last edit: Jim 2013-06-20