Page Up, Page Down, Home, and End in Catalyst Apps

Douglas Hill, following up on my piece yesterday on scrolling with standard keyboard shortcuts in UIKit and Catalyst apps:

I wish this was the case, but unfortunately it is not. The standard UIKit scrolling class, UIScrollView, does not provide any keyboard-driven scrolling functionality. […]

What’s going on here is that Apple did not add support for Page Up and Page Down in UIKit: They added this in WebKit/Safari. Fortunately WebKit is open source so we can see how they did it. Developers need to use the undocumented input strings UIKeyInputPageUp and UIKeyInputPageDown and write their own code to scroll up or down by the correct amount in response to those input events. While WebKit doesn’t support Home and End it’s possible to do some guessing: The strings UIKeyInputHome and UIKeyInputEnd do in fact work.

Hill has an open source framework, KeyboardKit, to fill these gaps.

Friday, 20 December 2019