"Use Your Numberpad To Control Google Hangouts/Meet" which is pretty handy. It uses a similar trick to play out a combination of keys and trigger actions in Chrome.
The script below watches the keyboard for the hyper key + another key. In the script below, I just bind the hyper key + some letter keys to trigger apps to focus.
-- verbose logging
-- hs.logger.setGlobalLogLevel(5)
local hyperKeyLogger = hs.logger.new('hyperkey','debug')
-- a table of mapping single keys to the apps they open/switch to
local hyper_key_shortcuts = {}
hyper_key_shortcuts["C"] = "Google Chrome"
hyper_key_shortcuts["F"] = "Finder"
hyper_key_shortcuts["S"] = "Sublime Text"
hyper_key_shortcuts["T"] = "WezTerm"
hyper_key_shortcuts["W"] = "WhatsApp"
hyper_key_shortcuts["Z"] = "Zed"
-- you can add some more apps here
-- sort through all the items in the table and add the listeners for them
for key,title in hs.fnutils.sortByKeys(hyper_key_shortcuts) do
hs.hotkey.bind({"cmd","ctrl","option","shift"}, key, title, function ()
hyperKeyLogger:v("[hyper "..key.."] pressed")
end, function ()
hyperKeyLogger:v("[hyper "..key.."] released")
-- @see https://www.hammerspoon.org/docs/hs.application.html#open
-- this will open the app if it is closed, or focus it if it is open
hs.application.open(title)
end, function ()
hyperKeyLogger:v("[hyper "..key.."] repeated")
end)
end
I'm a full-stack developer, co-organizer of PHP Vancouver meetup, and winner of a Canadian Developer 30 under 30 award. I'm a huge Open Source advocate and contributor to a lot of projects in my community. When I am not sitting at a computer, I'm trying to perfect some other skill.