https://github.com/keyboardkit/keyboardkit
KeyboardKit lets you create custom keyboard extensions with a few lines of code, using Swift & SwiftUI.
https://github.com/keyboardkit/keyboardkit
apple emoji ios keyboard keyboard-extension macos swift swiftui tvos visionos watchos
Last synced: about 14 hours ago
JSON representation
KeyboardKit lets you create custom keyboard extensions with a few lines of code, using Swift & SwiftUI.
- Host: GitHub
- URL: https://github.com/keyboardkit/keyboardkit
- Owner: KeyboardKit
- License: mit
- Created: 2016-08-19T01:43:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-05-09T16:43:40.000Z (5 days ago)
- Last Synced: 2025-05-09T17:46:08.795Z (5 days ago)
- Topics: apple, emoji, ios, keyboard, keyboard-extension, macos, swift, swiftui, tvos, visionos, watchos
- Language: Swift
- Homepage: https://keyboardkit.com
- Size: 76 MB
- Stars: 1,596
- Watchers: 27
- Forks: 241
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
![]()
# KeyboardKit
KeyboardKit lets you create amazing [custom keyboard extensions][About] 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][Pro], which unlocks localized keyboards, autocomplete, an emoji keyboard, AI support, themes, and much more.
## Installation
KeyboardKit can be installed with the Swift Package Manager:
```
https://github.com/KeyboardKit/KeyboardKit.git
```KeyboardKit must then be linked to all targets that will use it.
## Getting Started
The easiest way to set up KeyboardKit is to first create a `KeyboardApp` value for your app:
```swift
import KeyboardKitextension 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`:
```swift
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:
```swift
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:
```swift
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`:
```swift
@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][Getting-Started] and [essentials][Essentials] articles.
## Localization
KeyboardKit supports [73 locales][Localization]:
๐บ๐ธ ๐ฆ๐ฑ ๐ฆ๐ช ๐ฆ๐ฒ ๐ง๐พ ๐ง๐ฌ ๐ฆ๐ฉ ๐ณ๏ธ ๐ณ๏ธ ๐ญ๐ท
๐จ๐ฟ ๐ฉ๐ฐ ๐ณ๐ฑ ๐ง๐ช ๐ฆ๐บ ๐จ๐ฆ ๐ฌ๐ง ๐บ๐ธ ๐ช๐ช ๐ซ๐ด
๐ต๐ญ ๐ซ๐ฎ ๐ซ๐ท ๐จ๐ฆ ๐ง๐ช ๐จ๐ญ ๐ฌ๐ช ๐ฉ๐ช ๐ฆ๐น ๐จ๐ญ
๐ฌ๐ท ๐บ๐ธ ๐ฎ๐ฑ ๐ญ๐บ ๐ฎ๐ธ ๐ณ๏ธ ๐ฎ๐ฉ ๐ฎ๐ช ๐ฎ๐น ๐ฐ๐ฟ
๐น๐ฏ ๐น๐ฏ ๐น๐ฏ ๐ฑ๐ป ๐ฑ๐น ๐ฒ๐ฐ ๐ฒ๐พ ๐ฒ๐น ๐ฒ๐ณ ๐ณ๏ธ
๐ณ๐ด ๐ณ๐ด ๐ฎ๐ท ๐ต๐ฑ ๐ต๐น ๐ง๐ท ๐ท๐ด ๐ท๐บ ๐ท๐ธ ๐ท๐ธ
๐น๐ฏ ๐ธ๐ฐ ๐ธ๐ฎ ๐ช๐ธ ๐ฆ๐ท ๐ฒ๐ฝ ๐ธ๐ช ๐ฐ๐ช ๐น๐ท ๐บ๐ฆ
๐บ๐ฟ ๐ป๐ณ ๐ด๓ ง๓ ข๓ ท๓ ฌ๓ ณ๓ ฟKeyboardKit only includes localized strings, whileย [KeyboardKit Pro][Pro] unlocks localized keyboards, layouts, callouts and behaviors for all supported locales.
## Features
KeyboardKit provides a free, open-source keyboard engine. [KeyboardKit Pro][Pro] unlocks more powerful pro features.
* ๐ฑ [Essentials][Essentials] - Essential models, services, utilities & views.
* โจ๏ธ [Essentials-KeyboardView][Essentials-KeyboardView] - A native-looking, customizable keyboard.
* ๐ฅ [Actions][Actions] - Trigger & handle keyboard-related actions.
* ๐ฑ [App][App] - Set up your app, keyboard, sync settings, etc.
* ๐ฏ [Callouts][Callouts] - Show input & secondary action callouts.
* ๐ฅ๏ธ [Device][Device] - Identify device type, capabilities, etc.
* ๐ [Emojis][Emojis] - Emojis, categories, versions, skin tones, etc.
* ๐ [Feedback][Feedback] - Trigger audio & haptic feedback.
* ๐ [Gestures][Gestures] - Handle a rich set of gestures on any key.
* ๐ฃ [Layout][Layout] - Define and customize dynamic keyboard layouts.
* ๐ [Localization][Localization] - Additional locale-related utilities.
* ๐บ๏ธ [Navigation][Navigation] - Open urls and other apps from the keyboard.
* ๐ [Previews][Previews] - Extensive SwiftUI preview support.
* ๐ [Proxy][Proxy] - Extend the text document proxy with more capabilities.
* โ๏ธ [Settings][Settings] - Provide keyboard settings & link to System Settings.
* ๐ฉบ [Status][Status] - Detect if a keyboard is enabled, has full access, etc.
* ๐จ [Styling][Styling] - Style your keyboard to great extent.## Documentation
The [online documentation][Documentation] has a thorough getting-started guide, a detailed article for each feature, code samples, etc. You can also build it from the source code to get better formatting.
## Demo App
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.
> [!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.## KeyboardKit App
Download the [KeyboardKit app][KeyboardKit-App] from the App Store to try KeyboardKit without having to write any code or build the demo app from Xcode.
## Support This Project
KeyboardKit is open-source and completely free, but you can support the project by becoming a [GitHub Sponsor][Sponsors], upgrading to [KeyboardKit Pro][Pro] or [get in touch][Email] for freelance work, paid support etc.
## Contact
Feel free to reach out if you have questions or if you want to contribute in any way:
* Website: [keyboardkit.com][Website]
* E-mail: [[email protected]][Email]
* Bluesky: [@keyboardkit.bsky.social][Bluesky]
* Mastodon: [@[email protected]][Mastodon]## License
KeyboardKit is available under the MIT license. See the [LICENSE][License] file for more info.
[Email]: mailto:[email protected]
[Website]: https://keyboardkit.com
[Bluesky]: https://bsky.app/profile/keyboardkit.bsky.social
[Mastodon]: https://techhub.social/@keyboardkit
[Sponsors]: https://github.com/sponsors/danielsaidi[About]: https://keyboardkit.com/about
[Gumroad]: https://kankoda.gumroad.com
[KeyboardKit-App]: https://keyboardkit.com/app[KeyboardKit]: https://github.com/KeyboardKit/KeyboardKit
[Pro]: https://github.com/KeyboardKit/KeyboardKitPro
[Documentation]: https://keyboardkit.github.io/KeyboardKit/
[License]: https://github.com/KeyboardKit/KeyboardKit/blob/master/LICENSE[Getting-Started]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/getting-started-article
[Essentials]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/essentials-article
[Essentials-KeyboardView]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/essentials-keyboardview
[Essentials-Memory-Management]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/essentials-memory-management[Actions]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/actions-article
[AI]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/ai-article
[App]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/app-article
[Autocomplete]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/autocomplete-article
[Buttons]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/buttons-article
[Callouts]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/callouts-article
[Device]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/device-article
[Dictation]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/dictation-article
[Emojis]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/emojis-article
[External]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/external-keyboards-article
[Feedback]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/feedback-article
[Gestures]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/gestures-article
[Host]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/host-article
[Input]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/input-article
[Layout]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/layout-article
[Localization]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/localization-article
[Navigation]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/navigation-article
[Previews]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/previews-article
[Proxy]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/proxy-article
[Settings]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/settings-article
[Status]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/status-article
[Styling]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/styling-article
[Themes]: https://keyboardkit.github.io/KeyboardKit/documentation/keyboardkit/themes-article