mjolnir.hotkey

Create and manage global hotkeys.

bind

mjolnir.hotkey.bind(mods, key, pressedfn, releasedfn) -> hotkey

Shortcut for: return mjolnir.hotkey.new(mods, key, pressedfn, releasedfn):enable()

new

mjolnir.hotkey.new(mods, key, pressedfn, releasedfn = nil) -> hotkey

Creates a new hotkey that can be enabled.

The mods parameter is case-insensitive and may contain any of the following strings: "cmd", "ctrl", "alt", or "shift".

The key parameter is case-insensitive and may be any string value found in mjolnir.keycodes.map

The pressedfn parameter is the function that will be called when this hotkey is pressed.

The releasedfn parameter is the function that will be called when this hotkey is released; this field is optional (i.e. may be nil or omitted).

disable

mjolnir.hotkey:disable() -> self

Disables the given hotkey; does not remove it from mjolnir.hotkey.keys.

enable

mjolnir.hotkey:enable() -> self

Registers the hotkey's fn as the callback when the user presses key while holding mods.