A quick way to implement default features in UITextView for Better Keyboard (by Solfanto) (https://itunes.apple.com/app/better-keyboard-by-solfanto/id1049294250?ls=1&mt=8).
Better Keyboard is an iOS keyboard extension that simulates computer keyboards' shortcuts like ⌘+c
.
Unfortunately, the extension can't support the shortcuts by its own, the applications used with the keyboard must support the shortcuts as well.
If you own an iOS application, you can easily implement these shortcuts with this SDK. You can also read the source code and implement your own shortcuts.
If you own an iOS keyboard extension, we encourage you to also support shortcuts using the same API. (documentation coming soon)
To run the example project, clone the repo, and run pod install
from the Example directory first.
BetterKeyboardSDK is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "BetterKeyboardSDK", git: "git@github.com:n-studio/BetterKeyboardSDK.git"
Call these methods when implementing UITextViewDelegate or UITextFieldDelegate.
func textField(textField: UITextField, shouldChangeTextInRange range: NSRange, replacementString string: String) -> Bool {
return textField.bk_advancedTextFieldShouldChangeTextInRange(range, replacementString: string)
}
func textView(textView: UITextView, shouldChangeTextInRange range: NSRange, replacementText text: String) -> Bool {
return textView.bk_advancedTextViewShouldChangeTextInRange(range, replacementText: text)
}
func textViewDidChangeSelection(textView: UITextView) {
textView.bk_advancedTextViewDidChangeSelection()
}
⌘a: Select all
⌘c: Copy
⌘x: Cut
⌘v: Paste
⌘z: Undo
⌘y: Redo
⌘←: Select left
⌘→: Select right
⎋ or ␛: Escape (currently no effect)
The API is still in draft, feel free to open issues to make feature suggestions or any comment/criticism.
If the keyboard extension Better Keyboard (by Solfanto) itself has a bug, feel free to report it here.
Matthew Nguyen, Solfanto, Inc.
BetterKeyboardSDK is available under the MIT license. See the LICENSE file for more info.