Swiftpack.co -  KeyboardKit/KeyboardKit as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
KeyboardKit is a Swift library that helps you create custom keyboard extensions for iOS and ipadOS.
.package(url: "https://github.com/KeyboardKit/KeyboardKit.git", from: "4.4.0")


Version Platform Swift 5.3 MIT License Twitter: @danielsaidi

About KeyboardKit

KeyboardKit is a Swift library that helps you create custom keyboard extensions for iOS and iPadOS.

KeyboardKit contains tools for creating keyboards that mimic native iOS keyboards, as well as entirely custom ones. You can use any views you like and use the tools and extension in the library to create anything you like.

The end result can look something like this...or entirely different:

The movie above demonstrates an extensions that mimics a native keyboard. KeyboardKit lets you create rich system keyboards like that with support for multiple locales, multi-gestures, secondary action callouts etc.

If you're new to iOS keyboard extensions, this great guide will help you get started. You can also have a look at the demo app for inspiration.


Swift Package Manager



target 'MyApp' do
  pod 'KeyboardKit'

target 'MyKeyboard' do
  pod 'KeyboardKit'

post_install do |installer|
   installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
          config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No'

Getting Started

To build a keyboard extension with KeyboardKit, add KeyboardKit to your project as shown above.

If you use Swift Package Manager, make sure to add KeyboardKit to your keyboard extension. You can add it to your hosting app as well, but the keyboard extension must have it.

You should then inherit KeyboardInputViewController instead of UIInputViewController. It provides you with a lot of additional functionality, e.g. extra properties like keyboardContext, keyboardActionHandler, keyboardAppearance etc. The extension will also get access to autocomplete logic, extensions and much more.

KeyboardInputViewController has a setup(with:) function that can be used to setup your extension with any SwiftUI view. This will make it the main view of the extension, inject necessary environment objects and resize the keyboard extension to fit the view.

Have a look at the demo application and read more below to see how it all fits together.

SwiftUI vs. UIKit

KeyboardKit supports both SwiftUI and UIKit, but SwiftUI is the main focus going forward. The rest of this readme assumes that you're using SwiftUI. You can read more about UIKit support here.

Important about SwiftUI previews

KeyboardKit contains color and text resources that are embedded within the Swift package. However, SwiftUI previews outside this library can't access there resources, since the .module bundle isn't defined. This makes the previews crash.

Until this is solved in SwiftUI and SPM, call KeyboardPreviews.enable() in each preview to use fake colors and texts that don't break the preview.


๐Ÿ“ฆ Extensions

Even though KeyboardKit contains so much more, you can use its' extensions alone to simplify working with keyboard extensions. For instance, it has a bunch of UITextDocumentProxy extensions that make your life easier. Check out the demo apps and source code for examples and more information.

๐Ÿ’ฅ Keyboard Actions

KeyboardKit comes with many keyboard-specific actions, like character inputs, emojis, backspace, space, newline, image etc. You can even create your own actions.

Read more here

๐Ÿ˜Š Keyboard Types

KeyboardKit comes with many different keyboard types, like alphabetic, numeric, symbolic, emoji etc. You can even create your own types.

Read more here

๐Ÿ”ค Input Sets

KeyboardKit comes with an input set engine that make it easy to create alphabetic, numeric and symbolic keyboards in different languages.

Read more here

โŒจ๏ธ Keyboard Layouts

KeyboardKit comes with a layout engine that makes it easy to create specific keyboard layouts for various devices, orientations and locales.

Read more here

๐Ÿ‡ธ๐Ÿ‡ช Localization

KeyboardKit comes with built-in support for English keyboards and can be easily extended to support more locales. KeyboardKit also has a KKL10n enum that provides localized texts.

KeyboardKit Pro adds support for even more locales:

  • ๐Ÿ‡ฉ๐Ÿ‡ฐ Danish
  • ๐Ÿ‡ณ๐Ÿ‡ฑ Dutch
  • ๐Ÿ‡บ๐Ÿ‡ธ English (US)
  • ๐Ÿ‡ฌ๐Ÿ‡ง English (UK)
  • ๐Ÿ‡ซ๐Ÿ‡ฎ Finnish
  • ๐Ÿ‡ฉ๐Ÿ‡ช German
  • ๐Ÿ‡ฎ๐Ÿ‡น Italian
  • ๐Ÿ‡ณ๐Ÿ‡ด Norwegian
  • ๐Ÿ‡ธ๐Ÿ‡ช Swedish

Read more here

๐ŸŽจ Appearances

KeyboardKit lets you style your custom keyboards with custom appearances.

Read more here

๐Ÿ—ฏ Callouts

KeyboardKit lets you show callout bubbles as users type, as well as secondary action callouts with optional actions.

Read more here


KeyboardKit can present autocomplete suggestions as users type. The core library doesn't come with an implemented engine, but you can inject your own.

KeyboardKit Pro adds a localized autocomplete engine that provides localized suggestions.

Read more here

โœ‹ Haptic Feedback

KeyboardKit keyboards can give haptic feedback as users type.

Read more here.

๐Ÿ”ˆ Audio Feedback

KeyboardKit keyboards can give audio feedback as users type.

Read more here.

Demo Application

This repository contains a demo app that demonstrates different keyboards, like alphabetical (lowercased, uppercased and capslocked), numerical, symbols, emojis and images. It's not intended to be production ready, but rather to give you inspiration to how you can build your own keyboards.

To run the demo app, open and run the Demo/Demo.xcodeproj project, then enable the keyboards under system settings. Enable full access to support all features, like audio and haptic feedback.

KeyboardKit Pro

KeyboardKit Pro is a license-based extensions that unlocks pro features, such as additional locales and an autocomplete engine. Going pro is also a way to support this project.

Go Pro here!


Feel free to reach out if you have questions or if you want to contribute in any way:

Sponsors and Clients

This project is proudly sponsored by the following individuals and companies:

Oribi Logo Anomaly Software Logo Milo Creative Logo

You can support KeyboardKit by sponsoring the project on GitHub Sponsors, signing up for a KeyboardKit Pro license or hiring me for consultation.


KeyboardKit is available under the MIT license. See LICENSE file for more info.


Stars: 477
Last commit: Yesterday

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.

Release Notes

6 days ago

This version adds new locales as well as features that make it easier to work with layouts and collections.

In this version, you can also identify the active app ID, which makes it possible to adjust the keyboard accordingly.

There are also several tweaks and behavior changes that make system keyboards behave even more native-like.

โœจ New features

  • CGFloat has a new standardKeyboardButtonCornerRadius property.

  • DeleteBackwardRange is a new enum can be used when deleting backwards.

  • EnglishKeyboardInputSetProvider has new currency init params.

  • KeyboardAction.PrimaryType has new newLine case, that can be used to force an arrow for primary buttons.

  • KeyboardBehavior has a new backspaceRange property.

  • KeyboardColor is a new enum that exposes the raw color resources.

  • KeyboardContext has a new activeAppBundleId property that identifies the currently active app.

  • KeyboardContext has a new screenOrientation property that replaces deviceOrientation.

  • KeyboardPreviewMode is a new (hopefully temporary) class that has a static enable() function that makes SwiftUI previews work.

  • KeyboardInputViewController has a new activeAppBundleId property that identifies the currently active app.

  • RepeatGestureTimer has been made public and can be used to inspect how long a repeat gesture has been active.

  • RowItem is a new protocol that makes it possible to gather row collection functions in one place - Collection+RowItem.

  • Collection+RowItem has new extensions that make it easier to add and remove row items to all collections that contain the new RowItem protocol.

  • EdgeInsets+Keyboard has new context-based extensions.

  • UIInputViewController+Orientation renames deviceOrientation to screenOrientation.

  • UITextDocumentProxy+Delete has a new extension for deleting backwards a certain range.

๐ŸŒ New locales

  • ๐Ÿ‡ฌ๐Ÿ‡ง English U.K. (GB)
  • ๐Ÿ‡บ๐Ÿ‡ธ English U.S. (same keyboard as base English but different region)

๐Ÿ’ก Behavior changes

  • KeyboardAction now implements RowItem.

  • iPadKeyboardLayoutProvider has been adjusted layout buttons closer to native layouts.

  • iPhoneKeyboardLayoutProvider has been adjusted layout buttons closer to native layouts.

  • KeyboardInput now implements RowItem.

  • KeyboardLayoutItem now implements RowItem.

  • StandardKeyboardBehavior now only auto-switches keyboard type on .tap.

  • UITextDocumentProxy handles new lines when checking if the cursor is at new sentence.

  • Standard font sizes are adjusted to fit the native keyboards better.

  • The standard backspace range is now progressive and will increase after backspace has been pressed for a while.

๐Ÿ—‘ Deprecated (removed in 5.0):

  • KeyboardContext deviceOrientation has been renamed to screenOrientation.
  • UIApplication preferredKeyboardInterfaceOrientation didn't work and will be removed.
  • UIDeviceOrientation interfaceOrientation is no longer used and will be removed.
  • UIInputViewController deviceOrientation has been renamed to screenOrientation.
  • UIInterfaceOrientation - the device orientation-based init is no longer used and will be removed.

๐Ÿ’ฅ Breaking changes:

  • KeyboardBehavior has a new backspaceRange property that must be implemented.

Besides the points above, KeyboardActionHandler had a convenience handle function that didn't require a sender. This caused a conflict with the StandardKeyboardActionHandler function with the same signature. Subclassing StandardKeyboardActionHandler and calling super.handle thus caused a never-ending loop, since the convenience function called the sender function etc.

The sender-based functions have thus been removed. If you have a custom action handler that overrides handle or canHandle, you must remove the sender parameter.

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