Code Monkey home page Code Monkey logo

keyboardkit's Introduction

KeyboardKit Logo

Version Swift 5.9 Swift UI MIT License Twitter: @@getkeyboardkit Mastodon: @keyboardkit@techhub.social

About KeyboardKit

KeyboardKit is a Swift SDK that lets you create fully customizable keyboards in a few lines of code, using SwiftUI.

KeyboardKit extends Apple's native APIs and provides you with a lot more functionality. It lets you mimic the native iOS keyboard and tweak its style and behavior, or create completely custom keyboards.

Custom iOS keyboard extensions can be used with all other apps that support text input. It's the only way for your product, brand or technology to directly interact with other apps on iOS. Don't miss out!

KeyboardKit can be used in different ways. Keyboard extensions can use it to create custom keyboards. Apps can use it to check keyboard and full access status, provide settings etc.

Installation

KeyboardKit can be installed with the Swift Package Manager:

https://github.com/KeyboardKit/KeyboardKit.git

After installing KeyboardKit, make sure to link it to all targets that need it.

Getting Started

After installing KeyboardKit, just make your KeyboardViewController inherit KeyboardInputViewController instead of UIInputViewController:

import KeyboardKit

class KeyboardController: KeyboardInputViewController {}

This gives your controller access to new lifecycle functions like viewWillSetupKeyboard, observable state like state.keyboardContext, services like services.actionHandler, and much more.

If you just want to use the default SystemKeyboard view, which mimics a native iOS keyboard, you don't have to do anything else. KeyboardKit will set up everything.

To replace or customize the default SystemKeyboard, just override viewWillSetupKeyboard and call setup with a view builder:

class KeyboardViewController: KeyboardInputViewControllerย {

    override func viewWillSetupKeyboard() {
        super.viewWillSetupKeyboard()
        setup { [weak self] controller in // <-- Use [weak self] or [unowned self] if you need self here.
            SystemKeyboard(
                state: controller.state,
                services: controller.services,
                buttonContent: { $0.view },
                buttonView: { $0.view },
                emojiKeyboard: { $0.view },
                toolbar: { _ in MyCustomToolbar() }
            )
        }
    }
}

For more information, please see the getting started guide.

Supported Locales

KeyboardKit supports 63 keyboard-specific locales:

๐Ÿ‡ฆ๐Ÿ‡ฑ ๐Ÿ‡ฆ๐Ÿ‡ช ๐Ÿ‡ฆ๐Ÿ‡ฒ ๐Ÿ‡ง๐Ÿ‡พ ๐Ÿ‡ง๐Ÿ‡ฌ ๐Ÿ‡ฆ๐Ÿ‡ฉ ๐Ÿณ๏ธ ๐Ÿ‡ญ๐Ÿ‡ท ๐Ÿ‡จ๐Ÿ‡ฟ ๐Ÿ‡ฉ๐Ÿ‡ฐ
๐Ÿ‡ณ๐Ÿ‡ฑ ๐Ÿ‡ง๐Ÿ‡ช ๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿ‡ฌ๐Ÿ‡ง ๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿ‡ช๐Ÿ‡ช ๐Ÿ‡ซ๐Ÿ‡ด ๐Ÿ‡ต๐Ÿ‡ญ ๐Ÿ‡ซ๐Ÿ‡ฎ ๐Ÿ‡ซ๐Ÿ‡ท
๐Ÿ‡ง๐Ÿ‡ช ๐Ÿ‡จ๐Ÿ‡ญ ๐Ÿ‡ฌ๐Ÿ‡ช ๐Ÿ‡ฉ๐Ÿ‡ช ๐Ÿ‡ฆ๐Ÿ‡น ๐Ÿ‡จ๐Ÿ‡ญ ๐Ÿ‡ฌ๐Ÿ‡ท ๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿ‡ฎ๐Ÿ‡ฑ ๐Ÿ‡ญ๐Ÿ‡บ
๐Ÿ‡ฎ๐Ÿ‡ธ ๐Ÿณ๏ธ ๐Ÿ‡ฎ๐Ÿ‡ฉ ๐Ÿ‡ฎ๐Ÿ‡ช ๐Ÿ‡ฎ๐Ÿ‡น ๐Ÿ‡ฐ๐Ÿ‡ฟ ๐Ÿ‡น๐Ÿ‡ฏ ๐Ÿ‡น๐Ÿ‡ฏ ๐Ÿ‡น๐Ÿ‡ฏ ๐Ÿ‡ฑ๐Ÿ‡ป
๐Ÿ‡ฑ๐Ÿ‡น ๐Ÿ‡ฒ๐Ÿ‡ฐ ๐Ÿ‡ฒ๐Ÿ‡พ ๐Ÿ‡ฒ๐Ÿ‡น ๐Ÿ‡ฒ๐Ÿ‡ณ ๐Ÿ‡ณ๐Ÿ‡ด ๐Ÿณ๏ธ ๐Ÿ‡ฎ๐Ÿ‡ท ๐Ÿ‡ต๐Ÿ‡ฑ ๐Ÿ‡ต๐Ÿ‡น
๐Ÿ‡ง๐Ÿ‡ท ๐Ÿ‡ท๐Ÿ‡ด ๐Ÿ‡ท๐Ÿ‡บ ๐Ÿ‡ท๐Ÿ‡ธ ๐Ÿ‡ท๐Ÿ‡ธ ๐Ÿ‡ธ๐Ÿ‡ฐ ๐Ÿ‡ธ๐Ÿ‡ฎ ๐Ÿ‡ช๐Ÿ‡ธ ๐Ÿ‡ฐ๐Ÿ‡ช ๐Ÿ‡ธ๐Ÿ‡ช
๐Ÿ‡น๐Ÿ‡ท ๐Ÿ‡บ๐Ÿ‡ฆ ๐Ÿ‡บ๐Ÿ‡ฟ

KeyboardKit provides a basic keyboard layout with basic callout actions.ย KeyboardKit Pro provides localized layouts, callouts and behaviors for all supported locales.

Open-Source Features

KeyboardKit comes packed features to help you build amazing keyboard extensions:

  • โŒจ๏ธ Essentials - KeyboardKit provides essential utilities, types & views.
  • ๐Ÿ’ฅ Actions - KeyboardKit makes it easy to trigger keyboard-related actions.
  • ๐Ÿ’ก Autocomplete - KeyboardKit can perform autocomplete.
  • ๐Ÿ—ฏ Callouts - KeyboardKit can show input & secondary action callouts.
  • ๐ŸŒˆ Colors - KeyboardKit defines keyboard-specific colors.
  • ๐Ÿ–ฅ๏ธ Device - KeyboardKit has device-specific utilities.
  • ๐Ÿ˜€ Emojis - KeyboardKit defines emojis, categories, versions, skin tones, etc.
  • ๐Ÿ”‰ Feedback - KeyboardKit can trigger audio & haptic feedback.
  • ๐Ÿ‘† Gestures - KeyboardKit has a customizable keyboard gesture engine.
  • ๐Ÿ–ผ๏ธ Images - KeyboardKit defines keyboard-specific images.
  • ๐Ÿ”ฃ Layout - KeyboardKit has customizable input sets & keyboard layouts.
  • ๐ŸŒ Localization - KeyboardKit defines localized texts & assets for 63 locales.
  • ๐Ÿ—บ๏ธ Navigation - KeyboardKit lets you open urls and apps from the keyboard.
  • ๐Ÿ‘ Previews - KeyboardKit has extensive SwiftUI preview support.
  • โžก๏ธ Proxy - KeyboardKit extends UITextDocumentProxy with a lot more capabilities.
  • โš™๏ธ Settings - KeyboardKit has tools for in-app settings & System Settings.
  • ๐Ÿฉบ Status - KeyboardKit can detect if a keyboard is enabled, has full access, etc.
  • ๐ŸŽจ Styling - KeyboardKit lets you style your keyboards to great extent.

These features are all open-source and free to use. You can upgrade to KeyboardKit Pro to unlock Pro features.

KeyboardKit Pro

KeyboardKit Pro unlocks Pro features, like fully localized and locale-specific system keyboards, layouts & services, on-device and remote autocomplete & autocorrect, dictation, themes, etc.

  • โŒจ๏ธ Essentials - KeyboardKit Pro unlocks more essential tools, system keyboard previews, etc.
  • ๐Ÿ’ฅ Actions - KeyboardKit Pro auto-registers the most recently used emojis.
  • ๐Ÿค– AI - KeyboardKit Pro unlocks features that are needed for AI.
  • ๐Ÿ“ฑ App - KeyboardKit Pro unlocks app-specific screens & views.
  • ๐Ÿ’ก Autocomplete - KeyboardKit Pro unlocks on-device & remote autocomplete.
  • ๐Ÿ—ฏ Callouts - KeyboardKit Pro unlocks localized callouts for all locales.
  • ๐ŸŽค Dictation - KeyboardKit Pro can perform dictation from the keyboard.
  • ๐Ÿ˜€ Emojis - KeyboardKit Pro unlocks a powerful emoji keyboard.
  • โŒจ๏ธ External - KeyboardKit Pro can detect if an external keyboard is connected.
  • ๐Ÿ”‰ Feedback - KeyboardKit Pro unlocks tools for toogling feedback on & off.
  • ๐Ÿ”ฃ Layout - KeyboardKit Pro unlocks localized layouts for all locales.
  • ๐ŸŒ Localization - KeyboardKit Pro unlocks 63 locale-specific services and system keyboards.
  • ๐Ÿ‘ Previews - KeyboardKit Pro unlocks system keyboard and theme previews.
  • โžก๏ธ Proxy - KeyboardKit Pro unlocks ways for UIKit/UITextDocumentProxy to read the full document.
  • ๐Ÿ“ Text - KeyboardKit Pro unlocks tools to let you type within the keyboard.
  • ๐Ÿญ Themes - KeyboardKit Pro unlocks a theme engine with many pre-defined themes.

Every article in the documentation describes in detail what KeyboardKit Pro unlocks for that part of the SDK.

Documentation

The online documentation has more information, articles, code examples, etc.

Demo App

The demo app shows how to display keyboard state, link to system settings, etc.

The demo app has two demo keyboards:

  • Keyboard uses KeyboardKit and a customized SystemKeyboard.
  • KeyboardPro uses KeyboardKit Pro and enables all locales, autocomplete, themes, etc.

Just open and run the demo app in the Demo folder, then enable the keyboards under System Settings. Note that you need to enable full access for some features to work.

KeyboardKit App

If you want to try KeyboardKit Pro without having to write any code or build the demo app from Xcode, there is a KeyboardKit app in the App Store, that lets you try out many pro features.

Support This Project

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.

Contact

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

License

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

keyboardkit's People

Contributors

alfredcc avatar amirshane avatar andrewtavis avatar antonito avatar ardavank avatar brennanium avatar danielpunkass avatar danielsaidi avatar devzhr avatar digitalheir avatar f-person avatar gonzalonunez avatar hybridcattt avatar ibayramli avatar jackhumbert avatar jkristell avatar krizhanovskii avatar luffy-yu avatar micazeve avatar mirasaujan avatar pvinis avatar sirheimer avatar skellock avatar vuong-dao avatar wearhere avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

keyboardkit's Issues

Unit test new classes

While working on the 2.0 release, some parts of the major rewrite didn't get tested. They should be tested before the 2.1 release.

Switch to numeric keyboard on space

Native keyboards switch from numeric/symbol keyboard to the alpha one when space is tapped. KeyboardKit should do that as well, or at least provide a configuration to do so.

Switch keyboard within extension

KeyboardKit has a .switchKeyboard action that switches to the next system keyboard. However, it should also have a .toggleKeyboardMode action, so that buttons on the keyboard can toggle the keyboard state.

In the native keyboard, this is used by:

  • shift
  • shift lock
  • numeric toggle button
  • symbol toggle button

Full Access?

How do you actually do this?

"Enable full access in the Info.plist, if your keyboard needs it"

Press/repeat logic for some actions

The backspace action should have a press/repeat behavior, so that a user can press and hold to repeat that input until the user releases it.

Add support for toolbars

Besides button rows and collection views, KeyboardKit should have a toolbar item type. The demo keyboard should use one of these items as well, to show how they're implemented.

Starting out/beginner advice

I recently came across KeyboardKit repo and I had a quick question regarding building the keyboards.

Basically, I want to make a keyboard that just changes the label and output of the spacebar but the main problem is I donโ€™t have a ton of experience with Swift. Iโ€™ve followed all of your instructions for installation and everything seems to be okay, but in your examples you have files such as AlphabeticKeyboard.swift and DemoKeyboard.swift, but Iโ€™m not quite sure where these files would go in my Xcode project. I currently have a blank project with a custom keyboard extension and a default KeyboardViewController.swift file.

I know itโ€™s not your job to teach me Swift or anything but I was wondering if you could point me in the right direction. If I could get one of your example keyboards running then I could start to play around with it myself and figure it out but getting off the ground has proved tricky.

Any information you can give will be greatly appreciated.

Support for scrolling autocomplete result

At present autocomplete is a view that you can add labels etc to. It would be nice to have the option to have a scroll view that you can add an overflow of results.

Improve documentation

The documentation of the various classes and extensions are not great and should be improved.

How to show demo ?

I cloned this project , when I ran it ,after I tap the textview , just a system keyboard showed up, I didn't see the keyboard with the layout in the gif demo .

AutocompleteToolbar should be able to scroll itself instead of its buttons

The native autocomplete toolbar behavior is to display three autocomplete suggestions and distribute them evenly within the toolbar. If their text is too long, the labels become scrollable.

However, some users have expressed their need to display more content. They therefore need the toolbar to be able to give its views as much space as they need, and that the entire toolbar should become scrollable instead.

I have therefore added enableScrolling() and disableScrolling() to AutocompleteToolbar in KeyboardKit 2.6.1.

Bug - Missing NSPhotoLibraryAddUsageDescription

Hi @danielsaidi,

How are you?

I believe it's missing NSPhotoLibraryAddUsageDescription in info.plist in DemoKeyboard.

Keyboard[25674:404407] [access] This app has crashed because it 
attempted to access privacy-sensitive data without a usage description.  
The app's Info.plist must contain an NSPhotoLibraryAddUsageDescription 
key with a string value explaining to the user how the app uses this data.
(lldb) 

Regards,

Thiago

Adding a textfield inside a keyboard

Hi again,

Please, how can i create a Top Actions like this image below? I try to change this function:

 static func bottomActions(leftmost: KeyboardAction, for viewController: KeyboardViewController) -> KeyboardActionRow {
        let actions: [KeyboardAction] = [unathenticatedAction(for: viewController), leftmost, switchAction(for: viewController), .space, imageAction(for: viewController),  .newLine]
        let isEmoji: Bool = viewController.keyboardType == .emojis
        let isImage: Bool = viewController.keyboardType == .images
        let isUnathenticated: Bool = viewController.keyboardType == .custom("unathenticated")
        let includeImageActions: Bool = !isEmoji && !isImage && !isUnathenticated
        return includeImageActions ? actions : actions.withoutImageActions
    }

But no success :(

Also how can i add textfield inside a custom keyboard and label to it?

Sorry for my beginners doubts.

Some examples:

WhatsApp Image 2019-10-18 at 00 29 06

WhatsApp Image 2019-10-18 at 00 32 01

Thank you so much for the help

autocomplete support

Hello,

Can we use this release custom ios keyboard?

Can you please point to some examples to autocomplete models, both for offline dictionary and online dictionary
also if there is a way to use google services.

thanks,

AutocompleteBugFixTimer closes text input callouts

AutocompleteBugFixTimer solves the iOS text change bug by forcing the cursor to move. However, moving the cursor also causes any presented text field callouts to disappear.

I wanted to solve this by adding knowledge of the last detected current word to this timer, and avoid moving the cursor if the current word hasn't changed, but this does not work, since the cursor must be moved to update this information.

I can't find a way around this. I will release the autocomplete feature with this limitation, but would love to find a way to solve this problem in a better way.

Stack view configuration helpers

In KK 2.0, I will replace much of the earlier logic with stack views. This brings devs a lot of flexibility, but I'd like to add apis that make it easier to configure them for e.g. center display.

Constraint warnings

In KK 2.0, I base the keyboard on constraints instead of manual developer commands. However, there are a bunch of constraint warnings in the demo project, that I'd like to fix.

Multi language

Hi Daniel!
How to use another language in this keyboard?

Thanks!

Autocomplete: Text input does not trigger `textDidChange`

textDidChange(_ textInput: UITextInput?) isn't called when the user types and modifies the textDocumentProxy text. It gets called when you change the cursor position, however.

This function is critical to get autocomplete to work. Since the keyboard detects no text change, the autocomplete request isn't triggered and the old suggestions are still displayed even when the user writes or deletes text.

You can recreate this bug by selecting any word in the demo app. The demo autocomplete provider will change its suggestion to match the current word. Now type some text into the proxy - the old suggestions will not be replaced. Now change the cursor position - the app will now display new suggestions to match the new current word.

What is even more serious, is that even if you set a scheduled timer to trigger every second and call the autocomplete request, the currentWord will remain unchanged.

Add a double tap action.

The standard behaviour of double tap on "Space" button is to close the sentence. At the moment this could be implemented by handling "space" taps and measuring time between them. But it would be great if library contains a special action type for that event that would allow to specify which particular character has to be sent to proxy on space double tap.

RepeatingGestureRecognizer

Hi,
I was trying to implement the RepeatingGestureRecognizer for backspace - however it leads me weird results. Either the timer doesn't get invalidated or timer doesn't execute. So if you can share working code would be great help
Thanks

Autocomplete support

KeyboardKit should have autocomplete support, so that the keyboard can request auto complete suggestions from a autocomplete suggestion provider.

How to set Dark Mode?

Hello,

KeyboardKit supports dark mode but I couldn't find the "switch".
I want to enable/disable dark mode

Thank you

Eliminate tap lag

The current tap gesture recognizer adds a lag to the keyboard buttons, which is notable when you try to type fast. Eliminate this to make the keyboard as responsive as the system keyboard.

Word delimiters couldn't work in Chinese

Hi,

Becuase there is no space between two Chinese words, so the wordDelimiters won't work in my project.

https://github.com/danielsaidi/KeyboardKit/blob/151c47301b273e9bf5499cc9ec7dba101e4fe9f0/Sources/KeyboardKit/Extensions/UITextDocumentProxy%2BCurrentWord.swift#L74

The autocompleteSuggestions would consider all these characters as one word.

I think the correct way in typing Chinese could be:

  • When user start typing, the autocomplete start to match the suggestions.
  • When user tap to select a suggestion, the autocomplete stop, this match is finished.
  • When user start to type another word, the autocomplete restart to match for the new characters.

The autocomplete should use only the new typing chracters to match the suggestions.

Like this picture below, the autocomplete should only match the new characters hao, and leave the old words.

nospace

I'm not familiar with both programming and English, hope you not be confused, very thankful for this great work.

Thank you

KeyboardKit does not work on iOS 12.4

For iOS 12.4, i had added var window: UIWindow? in AppDelegate class to fix the black screen problem.

However, after looking at keyboard settings, i cannot find the keyboard.

But it works well for iOS 13. What is the minimum requirements for KeyboardKit? I will be looking at supporting older devices.

I am also downloading iOS 11.0 to see if it works there as well

Suggestion: Demo Create Keyboard from Storyboard

Hi @danielsaidi , first of all. Congratulations for your excellent Framework to create Custom Keyboards on iOS. This is helping me a lots to accomplish a personal project.

Could you provide a demo example using Storyboard to create an entire keyboard?

My kind regards,

Thiago

Audio Feedback

When switching from a native keyboard to a KeyboardKit one, the absence of audio feedback is annoying. KeyboardKit should provide a way to play audio feedback, as it does for haptics.

Enable scrolling toolbars

Today's toolbar view contains a stack view that can display toolbar items. However, the autocomplete toolbar should be able to enable scrolling, since it may want to display a large amount of items.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.