Skip to content

Instantly share code, notes, and snippets.

@yoheioka
Created May 16, 2020 03:59
Show Gist options
  • Save yoheioka/e291e22d87712f9c35a5cf1cc3e2fedf to your computer and use it in GitHub Desktop.
Save yoheioka/e291e22d87712f9c35a5cf1cc3e2fedf to your computer and use it in GitHub Desktop.
Hacking the Caps Lock Key Part 1
-- CONFIG FOR CAPS LOCK HACKING START
-- reference: https://github.com/lodestone/hyper-hacks/blob/master/hammerspoon/init.lua
-- A global variable for the Hyper Mode
k = hs.hotkey.modal.new({}, "F17")
local application_shortcuts = {
b = "Google Chrome",
u = "Sublime Text",
l = "LINE",
k = "Skype",
m = "Spotify",
f = "Finder",
p = "Preview",
n = "Notes",
s = "Slack",
q = "MySQLWorkbench",
c = "Visual Studio Code",
x = "Firefox",
w = "Microsoft Word",
}
for key, app_name in pairs(application_shortcuts) do
appfun = function()
hs.application.launchOrFocus(app_name)
k.triggered = true
end
k:bind('', key, nil, appfun)
end
-- -- Enter Hyper Mode when F18 (Hyper/Capslock) is pressed
pressedF18 = function()
k.triggered = false
k:enter()
end
-- Leave Hyper Mode when F18 (Hyper/Capslock) is released,
releasedF18 = function()
k:exit()
end
-- Bind the Hyper key
f18 = hs.hotkey.bind({}, 'F18', pressedF18, releasedF18)
-- CONFIG FOR CAPS LOCK HACKING END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment