29

GitHub - douglashill/KeyboardKit: A framework to help iOS and Mac Catalyst apps...

 4 years ago
source link: https://github.com/douglashill/KeyboardKit
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

KeyboardKit

KeyboardKit is a framework to help iOS and Mac Catalyst apps support being controlled using a hardware keyboard.

Keyboard control is a standard expectation of Mac apps. It’s important on iOS too because a hardware keyboard improves speed and ergonomics, which makes an iPad an even more powerful productivity machine.

Apps created with AppKit tend to have better support for keyboard control compared to UIKit-based apps. I believe the principal reason for this is that most AppKit components respond to key input out of the box, while most UIKit components do not. KeyboardKit aims to narrow this gap by providing subclasses of UIKit components that respond to key commands.

Status

This project is in its early stages, and is under active development. API stability is not guaranteed. So far these components are available:

  • KeyboardTableView(Controller): A UITableView(Controller) subclass that supports navigation and selection using arrow keys and space or return, including wrapping back to the top/bottom and selecting the top/bottom item by holding option. It also supports refreshing (⌘R) and scrolling with page up, page down, home and end. Does not support multiple selection except for selecting all rows (⌘A).
  • KeyboardCollectionView(Controller): A UICollectionView(Controller) subclass that supports navigation and selection using arrow keys and space or return. It supports refreshing (⌘R) and scrolling with page up, page down, home and end. Does not support multiple selection except for selecting all rows (⌘A). Does not support wrapping or selecting to the end by holding option.
  • KeyboardScrollView: A UIScrollView subclass that supports scrolling using arrow keys, space, page up, page down, home and end. It also supports zooming (⌘0, ⌘−, ⌘+).
  • KeyboardTextView: A UITextView subclass that supports find next (⌘G), find previous (⇧⌘G), use selection for find (⌘E), and jump to selection (⌘J).
  • KeyboardNavigationController: a UINavigationController subclass that supports going back (⌘←) and triggering the actions of the bar button items in the navigation bar and toolbar if they are instances of KeyboardBarButtonItem. Default key equivalents are provided for most system bar button items.
  • KeyboardTabBarController: A UITabBarController subclass that supports navigating between tabs using ⌘1, ⌘2 etc.
  • KeyboardWindow: A UIWindow subclass that supports using escape on a hardware keyboard to dismiss any topmost modal sheet or popover. Escape is available as ⌘. on Apple Smart Keyboards.
  • KeyboardApplication and KeyboardWindowScene: UIApplication and UIWindowScene subclasses that support making new windows (⌥⌘N), closing windows (⇧⌘W), cycling keyboard focus between visible windows (⌘`), and showing app settings in the Settings app (⌘,).

User facing text is currently only localised in English.

Requirements

At this early stage the project has only been tested on iOS 13 and Xcode 11.2.1. Supporting back to iOS 11 is not anticipated to be a problem.

KeyboardKit is written in Swift.

Usage

Instead of creating or subclassing a UIKit class directly, use the subclasses from KeyboardKit instead.

In order to receive key commands, an object must be on the responder chain.

Licence

MIT license — see License.txt


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK