{"id":20683163,"url":"https://github.com/chimehq/keycodes","last_synced_at":"2025-04-22T12:22:01.389Z","repository":{"id":63906878,"uuid":"420984336","full_name":"ChimeHQ/KeyCodes","owner":"ChimeHQ","description":"AppKit Carbon key codes to UIKey-compatible enums","archived":false,"fork":false,"pushed_at":"2024-07-12T15:28:16.000Z","size":42,"stargazers_count":36,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-15T20:20:48.358Z","etag":null,"topics":["appkit","keyboard","nsevent","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChimeHQ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":["mattmassicotte"]}},"created_at":"2021-10-25T10:50:46.000Z","updated_at":"2025-03-08T06:09:42.000Z","dependencies_parsed_at":"2024-03-26T04:30:55.218Z","dependency_job_id":null,"html_url":"https://github.com/ChimeHQ/KeyCodes","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"90f1d748200bda88c592537fd04163b36c2c57e6"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FKeyCodes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FKeyCodes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FKeyCodes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FKeyCodes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChimeHQ","download_url":"https://codeload.github.com/ChimeHQ/KeyCodes/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250237947,"owners_count":21397420,"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":["appkit","keyboard","nsevent","swift"],"created_at":"2024-11-16T22:15:37.679Z","updated_at":"2025-04-22T12:22:01.365Z","avatar_url":"https://github.com/ChimeHQ.png","language":"Swift","funding_links":["https://github.com/sponsors/mattmassicotte"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n[![Build Status][build status badge]][build status]\n[![Platforms][platforms badge]][platforms]\n[![Matrix][matrix badge]][matrix]\n\n\u003c/div\u003e\n\n# KeyCodes\n\nVersions of `UIKey`, `UIKeyboardHIDUsage`, and `UIKeyModifierFlags` that work with AppKit's `NSEvent`. No need for Carbon.HIToolbox. Aside from being a nicer API to work with, these versions should make it possible to more easily write source-compatible AppKit/UIKit keyboard handling code. Yes, this is basically a gigantic switch statement.\n\nThese structures are particularly helpful for writing tests. Constructing `NSEvent` instances by hand is a pain.\n\n## Usage\n\n```swift\nimport Carbon.HIToolbox\n\nfunc withoutKeyCodes(_ event: NSEvent) {\n    let code = Int(event.keyCode)\n    \n    if code == kVK_Return {\n        doThing()\n    }\n\n    if event.modifierFlags.deviceIndependentOnly.contains(.control) {\n        controlKeyActive()\n    }\n}\n\nimport KeyCodes\n\nfunc withKeyCodes(_ event: NSEvent) {\n    if event.keyboardHIDUsage == .keyboardReturn {\n        doThing()\n    }\n\n    // UIKeyModifierFlags-compatible\n    if event.keyModifierFlags.contains(.control) {\n        controlKeyActive()\n    }\n}\n```\n\n## Integration\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/ChimeHQ/KeyCodes\", from: \"0.1.1\")\n]\n```\n\n## Contributing and Collaboration\n\nI would love to hear from you! Issues or pull requests work great. A [Matrix space][matrix] is also available for live help, but I have a strong bias towards answering in the form of documenation.\n\nI prefer collaboration, and would love to find ways to work together if you have a similar project.\n\nI prefer indentation with tabs for improved accessibility. But, I'd rather you use the system you want and make a PR than hesitate because of whitespace.\n\nBy participating in this project you agree to abide by the [Contributor Code of Conduct](CODE_OF_CONDUCT.md).\n\n[build status]: https://github.com/ChimeHQ/KeyCodes/actions\n[build status badge]: https://github.com/ChimeHQ/KeyCodes/workflows/CI/badge.svg\n[platforms]: https://swiftpackageindex.com/ChimeHQ/KeyCodes\n[platforms badge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FChimeHQ%2FKeyCodes%2Fbadge%3Ftype%3Dplatforms\n[matrix]: https://matrix.to/#/%23chimehq%3Amatrix.org\n[matrix badge]: https://img.shields.io/matrix/chimehq%3Amatrix.org?label=Matrix\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchimehq%2Fkeycodes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchimehq%2Fkeycodes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchimehq%2Fkeycodes/lists"}