{"id":19778703,"url":"https://github.com/envoy/react-native-key-commands","last_synced_at":"2025-04-30T21:31:06.599Z","repository":{"id":47999628,"uuid":"125119999","full_name":"envoy/react-native-key-commands","owner":"envoy","description":"iOS UIKeyCommand native component for React Native","archived":false,"fork":false,"pushed_at":"2023-07-11T13:33:51.000Z","size":34,"stargazers_count":13,"open_issues_count":7,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2023-08-16T21:11:13.460Z","etag":null,"topics":["ios","react-native"],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","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/envoy.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}},"created_at":"2018-03-13T21:58:41.000Z","updated_at":"2023-08-16T21:11:13.461Z","dependencies_parsed_at":"2022-08-12T16:11:37.387Z","dependency_job_id":null,"html_url":"https://github.com/envoy/react-native-key-commands","commit_stats":null,"previous_names":[],"tags_count":5,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/envoy%2Freact-native-key-commands","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/envoy%2Freact-native-key-commands/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/envoy%2Freact-native-key-commands/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/envoy%2Freact-native-key-commands/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/envoy","download_url":"https://codeload.github.com/envoy/react-native-key-commands/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224224703,"owners_count":17276428,"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":["ios","react-native"],"created_at":"2024-11-12T05:30:53.896Z","updated_at":"2024-11-12T05:32:33.173Z","avatar_url":"https://github.com/envoy.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-key-commands\niOS [UIKeyCommand](https://developer.apple.com/documentation/uikit/uikeycommand) native component for React Native\n\n## Install\n\n```\nnpm install @envoy/react-native-key-commands\n```\n\nor \n\n```\nyarn add @envoy/react-native-key-commands\n```\n\nthen\n\n```\nreact-native link\n```\n\n## Usage\n\n```JSX\nimport React from 'react'\nimport { NativeSyntheticEvent } from 'react-native'\nimport KeyCommands, {\n  KeyCommand,\n  constants,\n} from '@envoy/react-native-key-commands'\n\n\nexport default class MyComponent: React.Component {\n  render () {\n    return (\n      \u003cKeyCommands\n        style={styles.myStyle}\n        keyCommands={[\n          {\n            input: keyCommandConstants.keyInputDownArrow,\n          },\n          {\n            input: \"1\",\n            keyModifier: constants.keyModifierCommand,\n            discoverabilityTitle: \"Do something cool\",\n          },\n          {\n            input: \"c\",\n            keyModifier: constants.keyModifierCommand\n          }\n        ]}\n        onKeyCommand={this.onKeyCommand}\u003e\n        \u003cView\u003e\n          {/* .. other views.. */}\n        \u003c/View\u003e\n      \u003c/KeyCommands\u003e\n    )\n  }\n  \n  private onKeyCommand = (event: NativeSyntheticEvent\u003cKeyCommand\u003e) =\u003e {\n    if (event.nativeEvent.input === '1' \u0026\u0026 event.keyModifiers === constants.keyModifierCommand) {\n      // do something here\n    }\n  }\n}\n```\n\nTo combine key modifiers, you can use `|` (bit-wise OR) operator, for example, you can define a shortcut `CMD + ALT + C` like this\n\n```js\n{\n  input: \"c\",\n  keyModifier: constants.keyModifierCommand | constants.,keyModifierAlternate\n  discoverabilityTitle: \"Do something cool\"\n}\n```\n\n## Constants\n\nConstants are exposed as `constatns` under the package. You can import it via\n\n```\nimport { constants } from '@envoy/react-native-key-commands'\n```\n\nHere's the value mapping from `constants` to iOS constant values\n\n - keyModifierShift: UIKeyModifierShift\n - keyModifierControl: UIKeyModifierControl\n - keyModifierAlternate: UIKeyModifierAlternate\n - keyModifierCommand: UIKeyModifierCommand\n - keyModifierNumericPad: UIKeyModifierNumericPad\n - keyInputUpArrow: UIKeyInputUpArrow\n - keyInputDownArrow: UIKeyInputDownArrow\n - keyInputLeftArrow: UIKeyInputLeftArrow\n - keyInputRightArrow: UIKeyInputRightArrow\n - keyInputEscape: UIKeyInputEscape\n \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenvoy%2Freact-native-key-commands","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenvoy%2Freact-native-key-commands","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenvoy%2Freact-native-key-commands/lists"}