Skip to content

Instantly share code, notes, and snippets.

@duanckham
Last active December 22, 2017 15:34
Show Gist options
  • Save duanckham/c2c610e7460565015243f1f6a8fda67f to your computer and use it in GitHub Desktop.
Save duanckham/c2c610e7460565015243f1f6a8fda67f to your computer and use it in GitHub Desktop.
-- Helper Functions
local function pressFn(mods, key)
if key == nil then
key = mods
mods = {}
end
return function() hs.eventtap.keyStroke(mods, key, 1000) end
end
local function remap(mods, key, pressFn)
hs.hotkey.bind(mods, key, pressFn, nil, pressFn)
end
-- For HHKB
remap({'rightalt'}, 'w', pressFn('up'))
remap({'rightalt'}, 'a', pressFn('left'))
remap({'rightalt'}, 's', pressFn('down'))
remap({'rightalt'}, 'd', pressFn('right'))
remap({'rightalt', 'cmd'}, 'w', pressFn({'cmd'}, 'up'))
remap({'rightalt', 'cmd'}, 'a', pressFn({'cmd'}, 'left'))
remap({'rightalt', 'cmd'}, 's', pressFn({'cmd'}, 'down'))
remap({'rightalt', 'cmd'}, 'd', pressFn({'cmd'}, 'right'))
remap({'rightalt', 'shift'}, 'w', pressFn({'shift'}, 'up'))
remap({'rightalt', 'shift'}, 'a', pressFn({'shift'}, 'left'))
remap({'rightalt', 'shift'}, 's', pressFn({'shift'}, 'down'))
remap({'rightalt', 'shift'}, 'd', pressFn({'shift'}, 'right'))
remap({'rightalt', 'cmd', 'shift'}, 'w', pressFn({'cmd', 'shift'}, 'up'))
remap({'rightalt', 'cmd', 'shift'}, 'a', pressFn({'cmd', 'shift'}, 'left'))
remap({'rightalt', 'cmd', 'shift'}, 's', pressFn({'cmd', 'shift'}, 'down'))
remap({'rightalt', 'cmd', 'shift'}, 'd', pressFn({'cmd', 'shift'}, 'right'))
remap({'cmd'}, 'escape', pressFn({'cmd'}, '`'))
-- For Windows Control
hs.hotkey.bind({'alt', 'cmd'}, '/', function()
hs.window.focusedWindow():moveToUnit(hs.layout.maximized)
end)
hs.hotkey.bind({'alt', 'cmd'}, ',', function()
hs.window.focusedWindow():moveToUnit(hs.layout.left50)
end)
hs.hotkey.bind({'alt', 'cmd'}, '.', function()
hs.window.focusedWindow():moveToUnit(hs.layout.right50)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment