Swiftpack.co -  douglashill/KeyboardKit as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
The easiest way to add comprehensive hardware keyboard control to an iPad or Mac Catalyst app.
.package(url: "https://github.com/douglashill/KeyboardKit.git", from: "4.4.1")


KeyboardKit makes it easy to add hardware keyboard control to iOS and Mac Catalyst apps.

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 because most AppKit components respond to key input out of the box, while most UIKit components do not. KeyboardKit narrows this gap by providing subclasses of UIKit components that respond to key commands.



KeyboardKit supports iOS 12.0 onwards on iPad, iPhone and Mac Catalyst (both scaled and optimised). tvOS is not supported. The latest Xcode 12.x is required.

⚠️ Xcode 13 (iOS 15 SDK) should not be used yet because the new UIKit focus system takes precedence over key commands, which means arrow keys will not work with KeyboardKit. Work is in progress integrating with the focus system. If you want a quick fix for arrow keys not working in table views and collection views when using the iOS 15 SDK, please use the xcode13 branch.

Both Swift and Objective-C apps are supported. Since KeyboardKit is implemented in Swift, it’s not possible subclass KeyboardKit classes from Objective-C. However all other features of KeyboardKit are available to Objective-C apps.


Swift Package Manager

Add KeyboardKit to an existing Xcode project as a package dependency:

  1. From the File menu, select Swift Packages › Add Package Dependency…
  2. Enter "https://github.com/douglashill/KeyboardKit" into the package repository URL text field.


  1. Clone this repository.
  2. Drag KeyboardKit.xcodeproj into your Xcode project.
  3. Add the KeyboardKit target as a dependency of your target.
  4. Add KeyboardKit.framework as an embedded framework.

This Swift package contains localised resources, so Swift 5.3 (Xcode 12) or later is required.

Swift Package Manager requires the Swift and Objective-C sources to be separated into modules. The KeyboardKitObjC module is used internally by KeyboardKit and does not need to be imported explicitly by your app.


KeyboardKit is available on CocoaPods as Keyboard-Kit.

Please open a pull request if you notice any integration problems.


Import the framework:

import KeyboardKit

Instead of creating or subclassing a UIKit class directly, use the subclasses from KeyboardKit instead. All KeyboardKit subclasses are named by changing UI to Keyboard. For example replace

class SettingsViewController: UICollectionViewController {


class SettingsViewController: KeyboardCollectionViewController {

Or create KeyboardKit subclasses directly:

let tabBarController = KeyboardTabBarController()
tabBarController.viewControllers = [
    KeyboardNavigationController(rootViewController: SettingsViewController()),

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

You can see more in the KeyboardKitDemo app, and each class includes API documentation in their Swift source file.


The public API is currently kept minimal so components are easy to drop in. If there is something you’d like to be able to customise in KeyboardKit, please open an issue to discuss. You could also consider directly integrating the source code and modify it as needed.

Learn more


KeyboardKit is a project from Douglas Hill with the kind help of contributors. Some concepts were originally developed for PSPDFKit and reimplemented in Swift for KeyboardKit. I use KeyboardKit in my reading app.


I’d love to have help on this project. For small changes please open a pull request, for larger changes please open an issue first to discuss what you’d like to see.

Tests are not required for new functionality, but fixed regressions should have automated tests. Use KeyboardKitTests for unit tests that don’t need views or a responder chain. Use KeyboardKitDemoUITests for integration tests that can be reproduced in the demo app. This only works on Mac Catalyst currently because iOS does not allow simulating hardware keyboard input. Use KeyboardKitUITests for any test cases between, which is probably most cases.


MIT license — see License.txt


Stars: 362
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API