lodestone / hyper-hacks

macOS Sierra hacks using some combination of Alfred 3, Karabiner-Elements, and Hammerspoon
MIT License
148 stars 27 forks source link

Performance isn't as good as hyper-key solution in original Karabiner/Seil #4

Closed vitalybe closed 7 years ago

vitalybe commented 7 years ago

I am writing here in case there is a solution I missed. The provided configuration works as described, but my problem is that it is slow, or rather, it isn't as responsive as it used to be under with the original Karabiner.

If I quickly flick the capslock+character combination (e.g in the same speed I press the cmd+c) it has a 50% chance of registering correctly. To be sure I have to hold capslock down for about a second.

Is it something you're experiencing? Any ideas about a solution?

Here is my current configuration for reference:

-- A global variable for the Hyper Mode
k = hs.hotkey.modal.new({}, "F17")

passthrough = function(key)
  -- hs.alert.show("Config loaded: " .. key)
  k.triggered = true
  hs.eventtap.keyStroke({"cmd","alt","shift","ctrl"}, key)
end

k:bind({}, 'c', nil, function() passthrough('c') end)
k:bind({}, 'f', nil, function() passthrough('f') end)
k:bind({}, 'e', nil, function() passthrough('e') end)
k:bind({}, 'p', nil, function() passthrough('p') end)
k:bind({}, '1', nil, function() passthrough('1') end)
k:bind({}, '2', nil, function() passthrough('2') end)
k:bind({}, '3', nil, function() passthrough('3') end)
k:bind({}, '4', nil, function() passthrough('4') end)
k:bind({}, '5', nil, function() passthrough('5') end)
k:bind({}, '6', nil, function() passthrough('6') end)
k:bind({}, '7', nil, function() passthrough('7') end)
k:bind({}, 'left', nil, function() passthrough('left') end)
k:bind({}, 'right', nil, function() passthrough('right') end)
k:bind({}, 'down', nil, function() passthrough('down') end)
k:bind({}, 'up', nil, function() passthrough('up') end)
k:bind({}, 'pagedown', nil, function() passthrough('pagedown') end)
k:bind({}, 'pageup', nil, function() passthrough('pageup') end)
k:bind({}, 'space', nil, function() passthrough('space') end)

ofun = function()
  hs.alert.show("Config loaded")
  hs.reload()
  k.triggered = true
end
k:bind({}, 'o', nil, ofun)

-- Enter Hyper Mode when F18 (Hyper/Capslock) is pressed
pressedF18 = function()
  k:enter()
  k.triggered = false
end

-- Leave Hyper Mode when F18 (Hyper/Capslock) is pressed
releasedF18 = function()
  k:exit()
  if not k.triggered then
    hs.eventtap.keyStroke({}, 'F19')
  end
end

-- Bind the Hyper key
hs.hotkey.bind({}, 'F18', pressedF18, releasedF18)
lodestone commented 7 years ago

@vitalybe I hadn't noticed too much degradation in speed personally but after poking around a bit I think I was able to duplicate what I think is happening for you.

The good news is: You are not alone! It is happening to me as well.

The bad news is: I don't have a fix for this.

In the sample init.lua I have HYPER+M set to open Alfred and HYPER+L to open a browser to Google News. Both of those keybindings seem to have the issue you mentioned.

I mostly use my Hyper setup these days to emulate CTRL for certain keys. On ^n and ^p I very rarely have an issue with responsiveness.

I wonder what would happen if you did something like:

k:bind({}, 'space', nil, function() 
  k.triggered = true
  hs.eventtap.keyStroke({"cmd","alt","shift","ctrl"},"space")
end)

Does skipping the additional function call help the speed at all?

gviridis commented 7 years ago

I encountered the same issue, but not that long as one second. I changed to https://spacelauncherapp.com recently. I still need to hold spacebar (hyper key for this app) for more than 0.2 seconds. It is intended for making a difference with inputting space (not very sure). The good thing is spacebar is very easy to be pressed with thumbs, much better than caps lock.

vitalybe commented 7 years ago

Does skipping the additional function call help the speed at all?

I'm afraid not.

I ended up removing hammerspoon completely, mapping caps-lock to F19 and using "Keyboard Maestro" for F19 combinations. I do give up on the ability of mapping CapsLock to another key (e.g Escape) but I needed the hyperkey combo functionality more.

lodestone commented 7 years ago

Sounds like everyone has found something that works for them for the time being.

Marking this closed.