Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually set a keyboard shortcut for a name #16

Closed
sindresorhus opened this issue Jun 22, 2020 · 2 comments · Fixed by #24
Closed

Manually set a keyboard shortcut for a name #16

sindresorhus opened this issue Jun 22, 2020 · 2 comments · Fixed by #24

Comments

@sindresorhus
Copy link
Owner

This can be useful for migrating over to this package from some other solution.

Inside some one-time migration method:

let shortcut = KeyboardShortcuts.Shortcut(carbonKeycode: someHotkey, carbonModifiers: someModifiers)

KeyboardShortcuts.Name.foo.shortcut = shortcut

Alternatively:

let shortcut = KeyboardShortcuts.Shortcut(carbonKeycode: someHotkey, carbonModifiers: someModifiers)

KeyboardShortcuts.Name.set(shortcut, for: .foo)

That way, the user doesn't need to know the implementation details on how it's stored. Like here: p0deje/Maccy@1001035#diff-2589021fe69dedfc5619fc6a19136f23R117-R126

@p0deje Any thoughts?

@sindresorhus sindresorhus changed the title Add method to manually set a keyboard shortcut for a name Manually set a keyboard shortcut for a name Jun 22, 2020
@p0deje
Copy link

p0deje commented Jun 22, 2020

This would be great indeed as I had to read through the sources to figure out the storage mechanism. Another possible solution would be to allow to customize storage strategy that can be implemented to provide backwards compatiblity during the app migration. The silly implementation I used to have was to just write "command+shift+C" string to my own UserDefaults, then parse it and construct a shortcut.

@sindresorhus
Copy link
Owner Author

Another possible solution would be to allow to customize storage strategy that can be implemented to provide backwards compatiblity during the app migration.

Agreed. I could use your thoughts in #18.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants