KeyboardKit helps you create custom keyboards for iOS and iPadOS, using technologies like Swift and SwiftUI. It extends Apple's native keyboard APIs and provides you with more functionality than what is otherwise available.
KeyboardKit lets you create keyboards that mimic the native iOS keyboards in a few lines of code. These keyboards can be customized to great extent to change input keys, layout, design, behavior etc.
KeyboardKit also lets you use completely custom views together with the features that the library provides. Most of the library can be used on all major Apple platforms.
KeyboardKit supports iOS 14
, macOS 11
, tvOS 14
and watchOS 7
, although some features are unavailable on some platforms.
KeyboardKit can be installed with the Swift Package Manager:
https://github.com/KeyboardKit/KeyboardKit.git
You can add the library to the main app, the keyboard extension and any other targets that need it. If you prefer to not have external dependencies, you can also just copy the source code into your app.
KeyboardKit is localized in 60+ keyboard-specific locales (read more):
🇦🇱 🇦🇪 🇦🇲 🇧🇾 🇧🇬 🇦🇩 🏳️ 🇭🇷 🇨🇿 🇩🇰
🇳🇱 🇧🇪 🇺🇸 🇬🇧 🇺🇸 🇪🇪 🇫🇴 🇵🇭 🇫🇮 🇫🇷
🇧🇪 🇨🇭 🇬🇪 🇩🇪 🇦🇹 🇨🇭 🇬🇷 🇺🇸 🇮🇱 🇭🇺
🇮🇸 🇮🇩 🇮🇪 🇮🇹 🇰🇿 🇹🇯 🇹🇯 🇹🇯 🇱🇻 🇱🇹
🇲🇰 🇲🇾 🇲🇹 🇲🇳 🇳🇴 🇮🇷 🇵🇱 🇵🇹 🇧🇷 🇷🇴
🇷🇺 🇷🇸 🇷🇸 🇸🇰 🇸🇮 🇪🇸 🇰🇪 🇸🇪 🇹🇷 🇺🇦
🇺🇿
KeyboardKit comes packed features to help you build amazing and powerful keyboards:
- 💥 Actions - KeyboardKit has keyboard actions like characters, emojis, actions, custom ones etc. and ways to handle them.
- 🎨 Appearance - KeyboardKit has an appearance engine that lets you style your keyboards to great extent.
- 💡 Autocomplete - KeyboardKit can perform autocomplete and present suggestions as the user types.
- 🗯 Callouts - KeyboardKit can show input callouts as the user types, as well as callouts with secondary actions.
- 🎤 Dictation - (BETA) KeyboardKit can perform dictation from the keyboard extension.
- 😊 Emojis - KeyboardKit defines emojis and emoji categories, as well as emoji keyboards.
- ⌨️ External Keyboards - KeyboardKit lets you detect whether or not an external keyboard is connected.
- 👋 Feedback - KeyboardKit keyboards can give and haptic feedback feedback as the user types.
- 👆 Gestures - KeyboardKit has keyboard-specific gestures that you can use in your own keyboards.
- 🔤 Input - KeyboardKit supports
alphabetic
,numeric
,symbolic
and completely custom input sets. - ⌨️ Keyboard - KeyboardKit supports different keyboard types, provides observable keyboard state, etc.
- 🔣 Layout - KeyboardKit supports creating keyboard layouts for various devices, locales etc.
- 🌐 Localization- KeyboardKit defines keyboard-specific locales with localized content and assets.
- 👁 Previews - KeyboardKit has utilites that help previewing keyboard views and components in SwiftUI.
- ➡️ Proxy - KeyboardKit extends
UITextDocumentProxy
and makes it do a lot more. - 🚏 Routing - KeyboardKit lets you route text to other destinations than the main app.
- ⬅️ RTL - KeyboardKit supports RTL (right-to-left) locales, such as Arabic, Persian, Kurdish Sorani etc.
- ⚙️ Settings - KeyboardKit has tools for accessing and linking to an app's keyboard settings.
The online documentation has a getting-started guide that will help you get started with the library.
After installing KeyboardKit, just import KeyboardKit
and make your KeyboardViewController
inherit KeyboardInputViewController
instead of UIInputViewController
to give your controller access to additional functionality, such as new lifecycle functions, observable properties, keyboard services and much more.
The default KeyboardInputViewController
behavior is to setup an English SystemKeyboard
keyboard. This is all the code that is required to achieve that:
import KeyboardKit
class KeyboardController: KeyboardInputViewController {}
The controller will then call viewWillSetupKeyboard()
when the keyboard view should be created or updated. You can override this function and call setup(with:)
to customize the default view or use a custom view.
For instance, here we replace the standard autocomplete toolbar with a custom toolbar:
class KeyboardViewController: KeyboardInputViewController {
func viewWillSetupKeyboard() {
super.viewWillSetupKeyboard()
setup { controller in
VStack(spacing: 0) {
MyCustomToolbar()
SystemKeyboard(
controller: controller,
autocompleteToolbar: .none
)
}
}
}
}
and here we use a completely custom view that requires the app-specific controller type:
class KeyboardViewController: KeyboardInputViewController {
func viewWillSetupKeyboard() {
super.viewWillSetupKeyboard()
setup { [unowned self] in
MyCustomKeyboard(
controller: self
)
}
}
}
struct MyCustomKeyboard: View {
@unowned
var controller: KeyboardViewController
var body: some View {
...
}
}
IMPORTANT When you use a custom view, it's very important to use [unowned self] in
in the view builder and that any controller
reference in the custom view is unowned
, otherwise the strong self
reference will cause a memory leak.
For more information, please see the online documentation and getting-started guide.
The online documentation has articles, code examples etc. that let you overview the various parts of the library and understand how they all connect to each other.
The online documentation is currently iOS-specific. To generate documentation for the other platforms, open the package in Xcode, select a simulator then run Product/Build Documentation
.
KeyboardKit Pro extends KeyboardKit with pro features, such as localized keyboards and services, autocomplete, dictation, emoji skintones, additional views etc. It lets you create fully localized keyboards with a single line of code.
If you want to try out KeyboardKit without having to write any code, there is a [KeyboardKit app][app-store] in the App Store, that lets you try out KeyboardKit and many of its features.
The App Store app uses KeyboardKit Pro to provide support for 60+ locales, autocomplete, dictation, emoji skintones etc.
This project has a demo app that lets you try out KeyboardKit and KeyboardKit Pro.
The main app shows you how to display the state of a keyboard extension, link to system settings etc. and has a text field to let you try out the keyboard.
The demo app has 5 keyboard extensions:
English
uses KeyboardKit and aSystemKeyboard
with a standard, English locale.Unicode
uses KeyboardKit and aSystemKeyboard
with unicode-based input keys.Custom
uses KeyboardKit and aSystemKeyboard
with custom keys, layout and appearance.Pro
uses KeyboardKit Pro and aSystemKeyboard
with all LRT locales, autocomplete etc.
Just open and run the demo app in the Demo
folder, then enable the keyboards you want to try under System Settings. Note that you need to enable full access to try some features, like audio and haptic feedback.
KeyboardKit is trusted and proudly sponsored by the following companies:
KeyboardKit is open-source and completely free, but you can sponsor this project on GitHub Sponsors, upgrade to KeyboardKit Pro or get in touch for freelance work, paid support etc.
Feel free to reach out if you have questions or if you want to contribute in any way:
- Website: keyboardkit.com
- Mastodon: @[email protected]
- Twitter: @getkeyboardkit
- E-mail: [email protected]
KeyboardKit is available under the MIT license. See the LICENSE file for more info.