local function keyStrokeFn(value) return function() hs.eventtap.keyStroke(value[1], value[2]) end end
local function pcallFn(f) return function() pcall(f) end end
function obj:bindModal(mod, key, action, modal) if type(action) == 'table' then if modal ~= nil then if action[3] == 'up' then modal:bind(mod, key, nil, keyStrokeFn(action)) else modal:bind(mod, key, keyStrokeFn(action), nil, keyStrokeFn(action)) end else if action[3] == 'up' then hs.hotkey.bind(mod, key, nil, keyStrokeFn(action)) else hs.hotkey.bind(mod, key, keyStrokeFn(action), nil, keyStrokeFn(action)) end end elseif type(action) == 'function' then if modal ~= nil then modal:bind(mod, key, pcallFn(action), nil, pcallFn(action)) else hs.hotkey.bind(mod, key, pcallFn(action), nil, pcallFn(action)) end end end