{"id":19252240,"url":"https://github.com/bellapplab/keyboard","last_synced_at":"2025-02-23T16:50:40.077Z","repository":{"id":36405973,"uuid":"40710905","full_name":"BellAppLab/Keyboard","owner":"BellAppLab","description":"Never implement UIKeyboardDidShowNotification ever again. Ever.","archived":false,"fork":false,"pushed_at":"2023-03-26T19:24:38.000Z","size":3957,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-05T21:06:21.170Z","etag":null,"topics":["carthage","cocoapods","ios","keyboard","swift","swift-package-manager"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BellAppLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-08-14T11:01:43.000Z","updated_at":"2025-02-04T17:29:46.000Z","dependencies_parsed_at":"2024-11-09T18:27:15.990Z","dependency_job_id":"18cc9b8e-0f2f-4c54-bdd2-d463dfc5bd2c","html_url":"https://github.com/BellAppLab/Keyboard","commit_stats":{"total_commits":31,"total_committers":1,"mean_commits":31.0,"dds":0.0,"last_synced_commit":"ece1073d726767fb166e5395055014b511fa51d8"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BellAppLab%2FKeyboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BellAppLab%2FKeyboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BellAppLab%2FKeyboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BellAppLab%2FKeyboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BellAppLab","download_url":"https://codeload.github.com/BellAppLab/Keyboard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240347944,"owners_count":19787236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["carthage","cocoapods","ios","keyboard","swift","swift-package-manager"],"created_at":"2024-11-09T18:26:06.622Z","updated_at":"2025-02-23T16:50:40.055Z","avatar_url":"https://github.com/BellAppLab.png","language":"Swift","readme":"# Keyboard [![Version](https://img.shields.io/badge/Version-1.1.0-black.svg?style=flat)](#installation) [![License](https://img.shields.io/cocoapods/l/Keyboard.svg?style=flat)](#license)\n\n[![Platforms](https://img.shields.io/badge/Platforms-iOS-brightgreen.svg?style=flat)](#installation)\n[![Swift support](https://img.shields.io/badge/Swift-3.3%20%7C%204.1%20%7C%204.2-red.svg?style=flat)](#swift-versions-support)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/Keyboard.svg?style=flat\u0026label=CocoaPods)](https://cocoapods.org/pods/Keyboard)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Swift Package Manager compatible](https://img.shields.io/badge/SPM-compatible-orange.svg?style=flat)](https://github.com/apple/swift-package-manager)\n[![Twitter](https://img.shields.io/badge/Twitter-@BellAppLab-blue.svg?style=flat)](http://twitter.com/BellAppLab)\n\n![Keyboard](./Images/keyboard.png)\n\n![Moving the keyboard using autolayout from the bottom of the screen](./Images/keyboard_pinned_bottom.gif)\n![Moving the keyboard using frame-based layout](./Images/keyboard_frame.gif)\n![Moving the keyboard using autolayout with mutiple text fields inside a view](./Images/keyboard_multiple.gif)\n\nNever implement `NSNotification.Name.UIKeyboardDidShow` ever again. Ever.\n\nYeah, seriously. Handling the keyboard on iOS shouldn't be painful. But it is. \n\nSo instead of doing a whole lot of calculations, or embedding everything in `UIScrollView`s, `import Keyboard` and **get on with your life**.\n\n## Specs\n\n* iOS 9+\n* Swift 4.2+\n\n## Usage\n\n### Step 1:\n\nMake your view controller conform to the `KeyboardChangeHandler` protocol: \n\n```swift\nimport Keyboard\n\n\nclass ViewController: UIViewController, KeyboardChangeHandler {\n```\n\n### Step 2:\n\nStart handling keyboard notifications:\n\n```swift\noverride func viewWillAppear(_ animated: Bool) {\n    super.viewWillAppear(animated)\n\n    becomeKeyboardChangeHandler()\n}\n\noverride func viewWillDisappear(_ animated: Bool) {\n    resignKeyboardChangeHandler()\n\n    super.viewWillDisappear(animated)\n}\n```\n\n### Step 3: \n\nctrl + drag to your favorite `NSLayoutConstraint`:\n\n![Interface Builder NSLayoutConstraint](./Images/interface_builder.png)\n\n### Step 4:\n\n**Get on with your life**\n\n## Goodies\n\n`Keyboard` comes with a couple of niceties you might enjoy:\n\n- The `Keyboard` singleton:\n\n```swift\nKeyboard.default.isVisible //tells you if the keyboard is currently visible\nKeyboard.default.currentFrame //tells you the keyboard's frame\n```\n\n- Turning keyboard handling off:\n\n```swift\nclass ViewController: UIViewController {\n    override func awakeFromNib() {\n        super.awakeFromNib()\n\n        //do this if you have set up a bunch of outlets on Interface Builder\n        //but don't want Keyboard to work on this view controller for now\n        handlesKeyboard = false\n    }\n}\n```\n\n- Keyboard margin:\n\n```swift\noverride func viewDidLoad() {\n    super.viewDidLoad()\n\n    [...]\n\n    //adds a margin between the keyboard and the currently active text input\n    //defaults to 40.0\n    keyboardMargin = 60.0\n}\n```\n\n- Finding the currently active text input:\n\n```swift\nself.view.currentFirstResponder\nUIResponder.currentFirstResponder\n```\n\n## Notes\n\n- If the Simulator doesn't show the keyboard straight away, press `cmd+K`.\n\n- You may get the following messages on the console (which don't affect the library in any way):\n\n```\n    _BSMachError: (os/kern) invalid capability (20)\n    _BSMachError: (os/kern) invalid name (15)\n```\n\n## Migrating\n\n- **From v0.6.0**: [Check this out](./MIGRATION.md) if you're migrating from version 0.6.0.\n\n## Installation\n\n### Cocoapods\n\n```ruby\npod 'Keyboard', '~\u003e 1.1'\n```\n\nThen `import Keyboard` where needed.\n\n### Carthage\n\n```swift\ngithub \"BellAppLab/Keyboard\" ~\u003e 1.1\n```\n\nThen `import Keyboard` where needed.\n\n### Swift Package Manager\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/BellAppLab/Keyboard\", from: \"1.1\")\n]\n```\n\nThen `import Keyboard` where needed.\n\n### Git Submodules\n\n```shell\ncd toYourProjectsFolder\ngit submodule add -b submodule --name Keyboard https://github.com/BellAppLab/Keyboard.git\n```\n\nThen drag the `Keyboard` folder into your Xcode project.\n\n## Author\n\nBell App Lab, apps@bellapplab.com\n\n### Credits\n\n[Logo image](https://thenounproject.com/search/?q=keyboard\u0026i=159048#) by [Gregor Cresnar ](https://thenounproject.com/grega.cresnar) from [The Noun Project](https://thenounproject.com/)\n\n## License\n\nKeyboard is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbellapplab%2Fkeyboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbellapplab%2Fkeyboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbellapplab%2Fkeyboard/lists"}