hs.hotkey.modal
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 |
|
| Source | extensions/hotkey/hotkey.lua line 552 |
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 |
|
| Source | extensions/hotkey/hotkey.lua line 482 |
delete
| Signature | hs.hotkey.modal:delete() |
|---|---|
| Type | Method |
| Description |
Deletes a modal hotkey object without calling :exited() |
| Parameters |
|
| Returns |
|
| Source | extensions/hotkey/hotkey.lua line 580 |
enter
| Signature | hs.hotkey.modal:enter() -> hs.hotkey.modal object |
|---|---|
| Type | Method |
| Description |
Enters a modal state |
| Parameters |
|
| Returns |
|
| Notes |
|
| Source | extensions/hotkey/hotkey.lua line 506 |
entered
| Signature | hs.hotkey.modal:entered() |
|---|---|
| Type | Method |
| Description |
Optional callback for when a modal is entered |
| Parameters |
|
| Returns |
|
| Notes |
|
| Source | extensions/hotkey/hotkey.lua line 452 |
exit
| Signature | hs.hotkey.modal:exit() -> hs.hotkey.modal object |
|---|---|
| Type | Method |
| Description |
Exits a modal state |
| Parameters |
|
| Returns |
|
| Notes |
|
| Source | extensions/hotkey/hotkey.lua line 530 |
exited
| Signature | hs.hotkey.modal:exited() |
|---|---|
| Type | Method |
| Description |
Optional callback for when a modal is exited |
| Parameters |
|
| Returns |
|
| Notes |
|
| Source | extensions/hotkey/hotkey.lua line 467 |
© 2014–2017 Hammerspoon contributors
Licensed under the MIT License.
https://www.hammerspoon.org/docs/hs.hotkey.modal.html