KeyboardKit is a SwiftUI SDK that lets you create fully customizable keyboard extensions with a few lines of code.
KeyboardKit extends Apple's limited keyboard APIs with more capabilities, and provides additional functionality, to let you build outstanding custom keyboards with little effort.
KeyboardKit is open-source and completely free. It can be extended with KeyboardKit Pro to unlock Pro features, like localized keyboards, autocomplete & autocorrect, AI support, an emoji keyboard, themes, dictation, and more.
Note
KeyboardKit 9 is soon out! Give it a try by using the 9.0.0-rc.6
tag. The online docs are updated for this major update. See the GitHub roadmap for remaining and closed issues.
KeyboardKit can be installed with the Swift Package Manager:
https://github.com/KeyboardKit/KeyboardKit.git
To use KeyboardKit in a keyboard extension, just import KeyboardKit
and let your KeyboardController
inherit KeyboardInputViewController
instead of UIInputViewController
:
import KeyboardKit
class KeyboardController: KeyboardInputViewController {}
This gives you access to lifecycle functions like viewWillSetupKeyboardView
, observable state, services, etc.
The easiest way to set up KeyboardKit is to create a KeyboardApp
value that defines information for your app:
extension KeyboardApp {
static var keyboardKitDemo: Self {
.init(
name: "KeyboardKit",
licenseKey: "keyboardkitpro-license-key",
bundleId: "com.keyboardkit.demo",
appGroupId: "group.com.keyboardkit.demo",
deepLinks: .init(app: "kkdemo://")
)
}
}
To set up your keyboard, just override viewDidLoad
and call setup(for:)
with your KeyboardApp
value:
class KeyboardViewController: KeyboardInputViewController {
override func viewDidLoad() {
super.viewDidLoad()
setup(for: .keyboardKitDemo)
}
}
To replace or customize the standard KeyboardView
keyboard, just override viewWillSetupKeyboardView
and call setupKeyboardView
with the view you want to use:
class KeyboardViewController: KeyboardInputViewController {
override func viewWillSetupKeyboardView() {
super.viewWillSetupKeyboardView()
setupKeyboardView { [weak self] controller in // <-- Use weak or unknowned self!
KeyboardView(
state: controller.state,
services: controller.services,
buttonContent: { $0.view },
buttonView: { $0.view },
collapsedView: { $0.view },
emojiKeyboard: { $0.view },
toolbar: { _ in MyCustomToolbar() }
)
}
}
}
To set up your main app with the same configuration, just wrap the root content view in a KeyboardAppView
:
import SwiftUI
import KeyboardKit
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
KeyboardAppView(for: .keyboardKitDemo) {
ContentView()
}
}
}
}
Setting up your app and keyboard with a KeyboardApp
will make settings sync between the two if an appGroupId
is defined, register your KeyboardKit Pro license if a licenseKey
is defined, set up dictation, deep links, etc.
For more information, see the getting started guide.
KeyboardKit supports 70 keyboard-specific locales:
🇺🇸 🇦🇱 🇦🇪 🇦🇲 🇧🇾 🇧🇬 🇦🇩 🏳️ 🇭🇷 🇨🇿
🇩🇰 🇳🇱 🇧🇪 🇦🇺 🇨🇦 🇬🇧 🇺🇸 🇪🇪 🇫🇴 🇵🇭
🇫🇮 🇫🇷 🇨🇦 🇧🇪 🇨🇭 🇬🇪 🇩🇪 🇦🇹 🇨🇭 🇬🇷
🇺🇸 🇮🇱 🇭🇺 🇮🇸 🏳️ 🇮🇩 🇮🇪 🇮🇹 🇰🇿 🇹🇯
🇹🇯 🇹🇯 🇱🇻 🇱🇹 🇲🇰 🇲🇾 🇲🇹 🇲🇳 🏳️ 🇳🇴
🇳🇴 🇮🇷 🇵🇱 🇵🇹 🇧🇷 🇷🇴 🇷🇺 🇷🇸 🇷🇸 🇸🇰
🇸🇮 🇪🇸 🇦🇷 🇲🇽 🇸🇪 🇰🇪 🇹🇷 🇺🇦 🇺🇿 🏴
KeyboardKit only includes localized strings, while KeyboardKit Pro unlocks localized keyboards, layouts, callouts and behaviors for all supported locales.
KeyboardKit is packed with features to help you build amazing custom keyboards:
- ⌨️ Essentials - Essential keyboard utilities, models, services & views.
- 💥 Actions - Trigger & handle keyboard-related actions.
- 📱 App - Define and set up your app, settings, etc.
- 💡 Autocomplete - Perform autocomplete as the user types.
- 🗯 Callouts - Show input & secondary action callouts.
- 🖥️ Device - Identify device type, device capabilities, etc.
- 😀 Emojis - Emojis, categories, versions, skin tones, etc.
- 🔉 Feedback - Trigger audio & haptic feedback with ease.
- 👆 Gestures - Handle a rich set of gestures on any key.
- 🔣 Layout - Define and customize dynamic keyboard layouts.
- 🌐 Localization - Localize your keyboard in 70 locales.
- 🗺️ Navigation - Open urls and other apps from the keyboard.
- 👁 Previews - Extensive SwiftUI preview support.
- 📄 Proxy - Extend the text document proxy with more capabilities.
- ⚙️ Settings - Provide keyboard settings & link to System Settings.
- 🩺 Status - Detect if a keyboard is enabled, has full access, etc.
- 🎨 Styling - Style your keyboard to great extent.
KeyboardKit Pro extends KeyboardKit with Pro features:
- ⌨️ Essentials - More essential tools, previews, toolbars, etc.
- 🤖 AI - Features that are needed for AI.
- 📱 App - App-specific screens & views.
- 💡 Autocomplete - Local & remote autocomplete, next word prediction, etc.
- 🗯 Callouts - Localized callout actions for all supported locales.
- 🎤 Dictation - Dictate text from the keyboard.
- 😀 Emojis - A powerful emoji keyboard, search, etc.
- ⌨️ External - Auto-detect if an external keyboard is connected.
- 🏠 Host - Identify and open specific host applications.
- 🔣 Layout - Localized layouts for all supported locales.
- 🌐 Localization - Services & views for all supported locales.
- 👁 Previews - Keyboard & theme previews for in-app use.
- 📄 Proxy - Allow
UITextDocumentProxy
to read the full document. - 📝 Text - Allow users to type within the keyboard.
- 🍭 Themes - A theme engine with many pre-defined themes.
The online documentation has a detailed article for each feature, a thorough getting-started guide, code samples, etc. You can also build it from the source code to get better formatting.
Note
The online documentation is updated for KeyboardKit 9.0 RC. Documentation for KeyboardKit 8 can be built from the source code.
The Demo
folder has a demo app that shows how to set up the main keyboard app, show keyboard status, provide in-app settings, link to system settings, apply custom styles, etc.
The app has two keyboards - a Keyboard
that uses KeyboardKit and a KeyboardPro
that uses KeyboardKit Pro. Note that you need to enable Full Access for some features to work, like haptic feedback.
Important
The demo isn't code signed and can therefore not use an App Group to sync settings between the app and its keyboards. As such, the KeyboardPro
keyboard has settings screens in the keyboard as well. You can try out the KeyboardKit app from the App Store to see how settings sync when you use a signed app.
If you want to try KeyboardKit without having to write any code or build the demo app from Xcode, the KeyboardKit app lets you try out many features by just downloading it from the App Store.
KeyboardKit is open-source and completely free, but you can support the project by becoming a GitHub Sponsor, upgrading 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.