Add method to remove all handlers (#36)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
This commit is contained in:
parent
02a18776d9
commit
d8a9321c4a
|
@ -46,6 +46,18 @@ public enum KeyboardShortcuts {
|
|||
// TODO: Should remove user defaults too.
|
||||
}
|
||||
|
||||
/**
|
||||
Remove all handlers receiving keyboard shortcuts events.
|
||||
|
||||
This can be used to reset the handlers before re-creating them to avoid having multiple handlers for the same shortcut.
|
||||
*/
|
||||
public static func removeAllHandlers() {
|
||||
keyDownHandlers = [:]
|
||||
keyUpHandlers = [:]
|
||||
userDefaultsKeyDownHandlers = [:]
|
||||
userDefaultsKeyUpHandlers = [:]
|
||||
}
|
||||
|
||||
// TODO: Also add `.isEnabled(_ name: Name)`.
|
||||
/**
|
||||
Disable a keyboard shortcut.
|
||||
|
|
Loading…
Reference in New Issue