Skip to content

Instantly share code, notes, and snippets.

@jsuo
Created June 19, 2017 04:00
Show Gist options
  • Save jsuo/90914d1bf30825387c481ed577fb0ddb to your computer and use it in GitHub Desktop.
Save jsuo/90914d1bf30825387c481ed577fb0ddb to your computer and use it in GitHub Desktop.
My Hammerspoon settings
local function keyCode(key, modifiers)
modifiers = modifiers or {}
return function() hs.eventtap.keyStroke(modifiers, key, 0) end
-- return function()
-- hs.eventtap.event.newKeyEvent(modifiers, string.lower(key), true):post()
-- hs.timer.usleep(100)
-- hs.eventtap.event.newKeyEvent(modifiers, string.lower(key), false):post()
-- end
end
local function remapKey(modifiers, key, keyCode)
hs.hotkey.bind(
modifiers, -- ctrl cmd alt shift
key, -- KeyCod
keyCode, -- Pressed
nil, -- Released
keyCode -- Repeat
)
end
-- カタカナに変換
remapKey({'cmd'}, 'i', keyCode('F7'))
-- vimm like
remapKey({'ctrl'}, 'h', keyCode('left'))
remapKey({'ctrl'}, 'j', keyCode('down'))
remapKey({'ctrl'}, 'k', keyCode('up'))
remapKey({'ctrl'}, 'l', keyCode('right'))
-- 行先頭
remapKey({'ctrl'}, 'g', keyCode('left', {'cmd'}))
-- 行末尾
remapKey({'ctrl'}, ';', keyCode('right', {'cmd'}))
-- page down
remapKey({'ctrl'}, 'f', keyCode('down', {'ctrl'}))
-- page up
remapKey({'ctrl'}, 'b', keyCode('up', {'ctrl'}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment