Skip to content

Commit

Permalink
Merge pull request #2762 from latenitefilms/patch-22
Browse files Browse the repository at this point in the history
Updated hs.hotkey.bind() documentation to match hs.hotkey.new()
  • Loading branch information
cmsj authored Mar 11, 2021
2 parents 68e23e6 + 22e8b42 commit 9bf1eb3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions extensions/hotkey/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,10 @@ function hotkey.showHotkeys(mods,key)
helpHotkey = hotkey.bind(mods,key,'Show active hotkeys',showHelp,alert.closeAll)
return helpHotkey
end
--- hs.hotkey.bind(mods, key, message, pressedfn, releasedfn, repeatfn) -> hs.hotkey object

--- hs.hotkey.bind(mods, key, [message,] pressedfn, releasedfn, repeatfn) -> hs.hotkey object
--- Constructor
--- Creates a hotkey and enables it immediately
--- Creates a new hotkey and enables it immediately
---
--- Parameters:
--- * mods - A table or a string containing (as elements, or as substrings with any separator) the keyboard modifiers required,
Expand All @@ -394,16 +395,23 @@ end
--- * "alt", "option" or "⌥"
--- * "shift" or "⇧"
--- * key - A string containing the name of a keyboard key (as found in [hs.keycodes.map](hs.keycodes.html#map) ), or a raw keycode number
--- * message - A string containing a message to be displayed via `hs.alert()` when the hotkey has been triggered, or nil for no alert
--- * message - (optional) A string containing a message to be displayed via `hs.alert()` when the hotkey has been
--- triggered; if omitted, no alert will be shown
--- * pressedfn - A function that will be called when the hotkey has been pressed, or nil
--- * releasedfn - A function that will be called when the hotkey has been released, or nil
--- * repeatfn - A function that will be called when a pressed hotkey is repeating, or nil
---
--- Returns:
--- * A new `hs.hotkey` object for method chaining
--- * A new `hs.hotkey` object or nil if the hotkey could not be enabled
---
--- Notes:
--- * This function is just a wrapper that performs `hs.hotkey.new(...):enable()`
--- * You can create multiple `hs.hotkey` objects for the same keyboard combination, but only one can be active
--- at any given time - see `hs.hotkey:enable()`
--- * If `message` is the empty string `""`, the alert will just show the triggered keyboard combination
--- * If you don't want any alert, you must *actually* omit the `message` parameter; a `nil` in 3rd position
--- will be interpreted as a missing `pressedfn`
--- * You must pass at least one of `pressedfn`, `releasedfn` or `repeatfn`; to delete a hotkey, use `hs.hotkey:delete()`
function hotkey.bind(...)
return hotkey.new(...):enable()
end
Expand Down

0 comments on commit 9bf1eb3

Please sign in to comment.