modal

Last updated 23 days ago

Create/manage modal keyboard shortcut environments

Usage: k = hs.hotkey.modal.new('cmd-shift', 'd') function k:entered() hs.alert'Entered mode' end function k:exited() hs.alert'Exited mode' end k:bind('', 'escape', function() k:exit() end) k:bind('', 'J', 'Pressed J',function() print'let the record show that J was pressed' end)

API Overview

  • Constructors - API calls which return an object, typically one that offers API methods

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

API Documentation

Constructors

new

Signature

hs.hotkey.modal.new(mods, key, message) -> hs.hotkey.modal object

Type

Constructor

Description

Creates a new modal state, optionally with a global keyboard combination to trigger it

Parameters

Returns

Notes

Methods

bind

Signature

hs.hotkey.modal:bind(mods, key, message, pressedfn, releasedfn, repeatfn) -> hs.hotkey.modal object

Type

Method

Description

Creates a hotkey that is enabled/disabled as the modal is entered/exited

Parameters

Returns

delete

Signature

hs.hotkey.modal:delete()

Type

Method

Description

Deletes a modal hotkey object without calling :exited()

Parameters

Returns

enter

Signature

hs.hotkey.modal:enter() -> hs.hotkey.modal object

Type

Method

Description

Enters a modal state

Parameters

Returns

Notes

entered

Signature

hs.hotkey.modal:entered()

Type

Method

Description

Optional callback for when a modal is entered

Parameters

Returns

Notes

exit

Signature

hs.hotkey.modal:exit() -> hs.hotkey.modal object

Type

Method

Description

Exits a modal state

Parameters

Returns

Notes

exited

Signature

hs.hotkey.modal:exited()

Type

Method

Description

Optional callback for when a modal is exited

Parameters

Returns

Notes