Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Latest commit

 

History

History
120 lines (101 loc) · 9.7 KB

cp.commands.shortcut.md

File metadata and controls

120 lines (101 loc) · 9.7 KB

docs » cp.commands.shortcut


Shortcut Commands

Submodules

API Overview

API Documentation

Functions

Signature cp.commands.shortcut.build(receiverFn) -> cp.commands.shortcut.builder
Type Function
Description Creates 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.
Signature cp.commands.shortcut.new(modifiers, keyCode) -> shortcut
Type Function
Description Creates 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.

Fields

Signature cp.commands.shortcut:isEnabled <cp.prop: boolean>
Type Field
Description If true, the shortcut is enabled.

Methods

Signature cp.commands.shortcut:bind(pressedFn, releasedFn, repeatedFn) -> shortcut
Type Method
Description This 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.
Signature cp.commands.shortcut:delete() -> shortcut
Type Method
Description Deletes a shortcut.
Parameters
  • None
Returns
  • self
Signature cp.commands.shortcut:disable() -> shortcut
Type Method
Description This disables the shortcut. If a hotkey has been bound, it will be disabled also.
Parameters
  • None
Returns
  • self
Signature cp.commands.shortcut:enable() -> shortcut
Type Method
Description This enables the shortcut. If a hotkey has been bound, it will be enabled also.
Parameters
  • None
Returns
  • self
Signature cp.commands.shortcut:getKeyCode() -> string
Type Method
Description Returns a string containing the keycode of the shortcut.
Parameters
  • None
Returns
  • string containing the keycode of the shortcut.
Signature cp.commands.shortcut:getModifiers() -> table
Type Method
Description Returns a table containing the modifiers for a shortcut.
Parameters
  • None
Returns
  • table containing the modifiers of the shortcut.
Signature cp.commands.shortcut:trigger() -> shortcut
Type Method
Description This will trigger the keystroke specified in the shortcut.
Parameters
  • None
Returns
  • self
Signature cp.commands.shortcut:unbind() -> shortcut
Type Method
Description Unbinds a shortcut.
Parameters
  • None
Returns
  • self