do some example like below:
local function pressFn(mods, oldKey, newKey)
return function()
if hs.application.frontmostApplication():name() == "Emacs" then
-- It does not work here
-- there are recursive calls
-- event bubbling ?
-- hs.eventtap.keyStroke(mods, oldKey, 1000)
else
hs.eventtap.keyStroke({}, newKey, 1000)
end
end
end
local function remap(mods, key, pressFn)
hs.hotkey.bind(mods, key, pressFn, nil, pressFn)
end
remap({'ctrl'}, 'h', pressFn({'ctrl'}, 'h', 'left'))
I hope it can ignore the Ctrl_h in Emacs application, how to implement this ?
I agree, something like this could be handy!
I was just looking for something like this and I was able to accomplish thing by disabling the binding when entering the application I wanted to ignore, and re-enabling it when leaving the application. I did this with hs.window.filter.
Something like this, with Xcode in my case:
yourBinding = hs.hotkey.bind(...)
local wf=hs.window.filter
xcodeWF = wf.new("Xcode")
xcodeWF:subscribe(wf.windowFocused, function()
yourBinding:disable()
end):subscribe(wf.windowUnfocused, function()
yourBinding:enable()
end)
Hope that helps!
@jiahut I found a working solution here.
@zef Thanks for the tip. Helped me a lot!
Most helpful comment
I agree, something like this could be handy!
I was just looking for something like this and I was able to accomplish thing by disabling the binding when entering the application I wanted to ignore, and re-enabling it when leaving the application. I did this with hs.window.filter.
Something like this, with Xcode in my case:
Hope that helps!