Skip to content

Conversation

@Maschina
Copy link
Contributor

@Maschina Maschina commented May 4, 2025

This PR adds a function to check the enablement status of a keyboard shortcut that has been set with enable(_:) or disable(_:).

I am using this function in my project to implement a SwiftUI Toggle to enable/disable a shortcut without clearing the Shortcut setting in the UserDefaults instance.

Example

// Check if the "toggleUnicornMode" shortcut is enabled
let isEnabled = KeyboardShortcuts.isEnabled(for: .toggleUnicornMode)

@sindresorhus
Copy link
Owner

Should it respect the global .isEnabled?

@Maschina
Copy link
Contributor Author

Maschina commented May 6, 2025

Should it respect the global .isEnabled?

Good catch. Yes, it should. I will make a change accordingly.

@Maschina Maschina requested a review from sindresorhus May 6, 2025 12:53
@sindresorhus
Copy link
Owner

Merge conflict

@sindresorhus sindresorhus merged commit f92c39e into sindresorhus:main May 7, 2025
1 check passed
@Maschina Maschina deleted the isEnabledPerName branch May 8, 2025 10:38
Maschina added a commit to Maschina/KeyboardShortcuts that referenced this pull request May 9, 2025


* 'main' of https://github.com/sindresorhus/KeyboardShortcuts:
  Tweaks
  Add `isEnabled()` method (sindresorhus#215)

# Conflicts:
#	Sources/KeyboardShortcuts/KeyboardShortcuts.swift
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 this pull request may close these issues.

2 participants