Just thought I’d record here that if this is to be implemented as a macro along the lines of this solution, it is better to use if (keyIsPressed(keyState))
rather than if (keyToggledOn(keyState))
normally used for macros.
Only then do we get a smooth experience comparable to scroll up/down with the unmodified keys Key_mouseScrollUp and Key_mouseScrollDn which give their effect as long as they are pressed and not once when toggled on ie initially pressed.