#cp.commands.shortcut

Shortcut Commands


#Submodules


#API Overview

Functions - API calls offered directly by the extension

Fields - Variables which can only be accessed from an object returned by a constructor

Methods - API calls which can only be made on an object returned by a constructor


#API Documentation

#Functions

Signaturecp.commands.shortcut.build(receiverFn) -> cp.commands.shortcut.builder
TypeFunction
DescriptionCreates a new shortcut builder.
Parameters
  • receiverFn - (optional) a function which will get passed the shortcut when the build is complete.
Returns
  • shortcut.builder which can be used to create the shortcut.
Notes
  • If provided, the receiver function will be called when the shortcut has been configured, and passed the new
  • shortcut. The result of that function will be returned to the next stage.
  • If no receiverFn is provided, the shortcut will be returned directly.
  • The builder is additive. You can create a complex keystroke combo by
  • chaining the shortcut names together.
  • For example:
  • local myShortcut = shortcut.build():cmd():alt("x")
  • Alternately, provide a receiver function and it will get passed the shortcut instead:
  • shortcut.build(function(shortcut) self._myShortcut = shortcut end):cmd():alt("x")
ExamplesNone
Sourcesrc/extensions/cp/commands/shortcut.lua line 69

Signaturecp.commands.shortcut.new(modifiers, keyCode) -> shortcut
TypeFunction
DescriptionCreates a new keyboard shortcut, attached to the specified hs.commands.command
Parameters
  • modifiers - The modifiers.
  • keyCode - The key code.
Returns
  • shortcut - The shortcut that was created.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/commands/shortcut.lua line 51

#Fields

Signaturecp.commands.shortcut:isEnabled <cp.prop: boolean>
TypeField
DescriptionIf true, the shortcut is enabled.
NotesNone
Sourcesrc/extensions/cp/commands/shortcut.lua line 124

#Methods

Signaturecp.commands.shortcut:bind(pressedFn, releasedFn, repeatedFn) -> shortcut
TypeMethod
DescriptionThis function binds the shortcut to a hotkey, with the specified callback functions for pressedFn, releasedFn and repeatedFn.
Parameters
  • pressedFn - (optional) If present, this is called when the shortcut combo is pressed.
  • releasedFn - (optional) If present, this is called when the shortcut combo is released.
  • repeatedFn - (optional) If present, this is called when the shortcut combo is repeated.
Returns
  • self
Notes
  • If the shortcut is enabled, the hotkey will also be enabled at this point.
ExamplesNone
Sourcesrc/extensions/cp/commands/shortcut.lua line 169

Signaturecp.commands.shortcut:delete() -> shortcut
TypeMethod
DescriptionDeletes a shortcut.
Parameters
  • None
Returns
  • self
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/commands/shortcut.lua line 231

Signaturecp.commands.shortcut:disable() -> shortcut
TypeMethod
DescriptionThis disables the shortcut. If a hotkey has been bound, it will be disabled also.
Parameters
  • None
Returns
  • self
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/commands/shortcut.lua line 155

Signaturecp.commands.shortcut:enable() -> shortcut
TypeMethod
DescriptionThis enables the shortcut. If a hotkey has been bound, it will be enabled also.
Parameters
  • None
Returns
  • self
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/commands/shortcut.lua line 141

Signaturecp.commands.shortcut:getKeyCode() -> string
TypeMethod
DescriptionReturns a string containing the keycode of the shortcut.
Parameters
  • None
Returns
  • string containing the keycode of the shortcut.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/commands/shortcut.lua line 111

Signaturecp.commands.shortcut:getModifiers() -> table
TypeMethod
DescriptionReturns a table containing the modifiers for a shortcut.
Parameters
  • None
Returns
  • table containing the modifiers of the shortcut.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/commands/shortcut.lua line 98

Signaturecp.commands.shortcut:trigger([app]) -> shortcut
TypeMethod
DescriptionThis will trigger the keystroke specified in the shortcut.
Parameters
  • app - An optional hs.application object.
Returns
  • self
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/commands/shortcut.lua line 244

Signaturecp.commands.shortcut:unbind() -> shortcut
TypeMethod
DescriptionUnbinds a shortcut.
Parameters
  • None
Returns
  • self
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/commands/shortcut.lua line 212