When a reassignment of a hyper key / cap is blocked by F18 using Hammerspoon, is it possible to use it with modifiers

My problem is this: I have a header lock redone in F18 using Karabiner Elements, and then Hammerspoon uses F18 as a “hyper key” to execute application shortcuts.

My current code is as follows:

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

launch = function(bundleID)
  hs.application.launchOrFocusByBundleID(bundleID)
  k.triggered = true
end

-- Single keybinding for app launch
singleapps = {
  {'f', 'com.apple.Finder'},
  {'c', 'com.google.Chrome'},
}

for i, app in ipairs(singleapps) do
  k:bind({}, app[1], function() launch(app[2]); end, nil, function() launch(app[2]); end)

I also have HJKJ mapped to arrow keys when using a hyper key so that you can navigate vim everywhere:

arrowKey = function(arrow, modifiers) 
  local event = require("hs.eventtap").event
  event.newKeyEvent(modifiers, string.lower(arrow), true):post()
  event.newKeyEvent(modifiers, string.lower(arrow), false):post()
end

k:bind({}, 'h', function() arrowKey('LEFT', {}); end, nil, function() arrowKey('LEFT', {}); end)
k:bind({}, 'j', function() arrowKey('DOWN', {}); end, nil, function() arrowKey('DOWN', {}); end)
k:bind({}, 'k', function() arrowKey('UP', {}); end, nil, function() arrowKey('UP', {}); end)
k:bind({}, 'l', function() arrowKey('RIGHT', {}); end, nil, function() arrowKey('RIGHT', {}); end)

So, HYPER-Hdisplays the left arrow basically. But my problem is that I also want the HYPER-COMMAND-Hleft arrow command to be displayed, as this brings the cursor to the beginning of the line.

k:bind({'cmd'}, 'n', function() arrowKey('LEFT', {'cmd'}); end, nil, function() arrowKey('LEFT', {'cmd'}); end)

. , HYPER-COMMAND-H , COMMAND-HYPER-H . ( ), , .

, ? F18 -, .

+4

Source: https://habr.com/ru/post/1663156/


All Articles