KeyboardKit lets you create amazing custom keyboard extensions with a few lines of code, using Swift & SwiftUI.
KeyboardKit extends Apple's limited keyboard APIs with more capabilities. It can be extended with KeyboardKit Pro, which unlocks localized keyboards, autocomplete, an emoji keyboard, AI support, themes, and much more.
KeyboardKit can be installed with the Swift Package Manager:
https://github.com/KeyboardKit/KeyboardKit.git
Since KeyboardKit is a binary framework, it must only linked to the main app target. All other targets will be able to use it without linking.
The easiest way to set up KeyboardKit is to first create a KeyboardApp
value for your app:
import KeyboardKit
extension KeyboardApp {
static var keyboardKitDemo: KeyboardApp {
.init(
name: "KeyboardKit",
licenseKey: "your-key-here", // Needed for KeyboardKit Pro!
appGroupId: "group.com.keyboardkit.demo", // Sets up App Group data sync
locales: .keyboardKitSupported, // Sets up the enabled locales
autocomplete: .init( // Sets up custom autocomplete
nextWordPredictionRequest: .claude(...) // Sets up AI-based prediction
),
deepLinks: .init(app: "kkdemo://", ...) // Defines how to open the app
)
}
}
Next, let your KeyboardController
inherit KeyboardInputViewController
instead of UIInputViewController
:
class KeyboardController: KeyboardInputViewController {}
This unlocks additional functions and capabilities, and adds services
and observable state
to the controller.
Next, override viewDidLoad()
and call setup(for:)
to set up the keyboard extension for your app:
class KeyboardViewController: KeyboardInputViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Set up the keyboard with the app we created above
setup(for: .keyboardKitDemo) { result in
// If `result` is `.success`, the setup did succeed.
// This is where you can setup custom services, etc.
}
}
}
This will make keyboard settings sync data between the main app and its keyboard if the KeyboardApp
defines an appGroupId
, set up KeyboardKit Pro if it defines a licenseKey
, set up dictation and deep links, etc.
To replace or customize the standard KeyboardView
, just override viewWillSetupKeyboardView()
and let it call setupKeyboardView(_:)
with the view that you want to use:
class KeyboardViewController: KeyboardInputViewController {
override func 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: { $0.view }
)
}
}
}
To set up your main app with the same keyboard configuration, just wrap the content view in a KeyboardAppView
:
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
// Here we use the keyboard app we created above
KeyboardAppView(for: .keyboardKitDemo) {
ContentView()
}
}
}
}
For more information, see the getting started guide and essentials articles.
KeyboardKit supports 75 locales:
🇺🇸 🇦🇱 🇦🇪 🇦🇲 🇦🇿 🇧🇾 🇧🇩 🇧🇬 🇦🇩 🏳️
🏳️ 🇭🇷 🇨🇿 🇩🇰 🇳🇱 🇧🇪 🇦🇺 🇨🇦 🇬🇧 🇺🇸
🇪🇪 🇫🇴 🇵🇭 🇫🇮 🇫🇷 🇨🇦 🇧🇪 🇨🇭 🇬🇪 🇩🇪
🇦🇹 🇨🇭 🇬🇷 🇺🇸 🇮🇱 🇭🇺 🇮🇸 🏳️ 🇮🇩 🇮🇪
🇮🇹 🇰🇿 🇹🇯 🇹🇯 🇹🇯 🇱🇻 🇱🇹 🇲🇰 🇲🇾 🇲🇹
🇲🇳 🏳️ 🇳🇴 🇳🇴 🇮🇷 🇵🇱 🇵🇹 🇧🇷 🇷🇴 🇷🇺
🇷🇸 🇷🇸 🇹🇯 🇸🇰 🇸🇮 🇪🇸 🇦🇷 🇲🇽 🇸🇪 🇰🇪
🇹🇷 🇺🇦 🇺🇿 🇻🇳 🏴
KeyboardKit Pro unlocks localized keyboards, layouts, callouts and behaviors for all supported locales.
KeyboardKit provides a free, open-source keyboard engine. KeyboardKit Pro unlocks more powerful pro features.
- 🌱 Essentials - Essential utilities, models, services & views.
- ⌨️ Essentials - KeyboardView - Render a native-looking, fully customizable keyboard.
- 💥 Actions - Trigger & handle keyboard-related actions.
- 🤖 AI - Features that are needed by AI-based keyboards.
- 📱 App - App-specific utilities, settings, screens, etc.
- 💡 Autocomplete - Autocomplete and autocorrect as the user types.
- 🗯 Callouts - Show input & secondary action callouts.
- 📋 Clipboard - Create custom clips and integrate with the system clipboard.
- 🖥️ Device - Identify device type, device capabilities, etc.
- 🎤 Dictation - Trigger dictation from the keyboard.
- 😀 Emojis - Emoji models, an emoji keyboard, etc.
- ⌨️ External - Detect if an external keyboard is connected.
- 🔉 Feedback - Trigger audio & haptic feedback with ease.
- 𝒜 Fonts - Type with other fonts than the standard system font.
- 👆 Gestures - Handle a rich set of gestures on any key.
- 🏠 Host - Identify and open the host application.
- 📝 Input - Keyboard input fields, Vietnamese support, etc.
- 🔣 Layout - A dynamic, customizable keyboard layout engine.
- 🌐 Localization - Locale-specific utilities for all supported locales.
- 🗺️ Navigation - Open urls and other apps from the keyboard.
- 👁 Previews - Keyboard & theme previews for in-app use.
- 📄 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.
- 🍭 Themes - A theme engine with many pre-defined themes.
The online documentation has a getting-started guide, feature articles, code samples, developer guides, etc.
The Demo
folder has a demo app that shows how to set up a main app and its keyboard extension, show keyboard status, provide in-app settings, link to system settings, apply custom styles, etc.
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 keyboard settings in the keyboard as well.
The KeyboardKit app on the App Store lets you download and try KeyboardKit without having to write any code.
KeyboardKit is free to use, but you can support us 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
- E-mail: info@keyboardkit.com
- Bluesky: @keyboardkit.bsky.social
- Mastodon: @keyboardkit@techhub.social
KeyboardKit is closed-source. See the LICENSE file for more info.