/hammerspoon-config

My Hammerspoon configuration files.

Primary LanguageLuaMIT LicenseMIT

Update (Feb 23, 2022): I have switched to using Karabiner for handling all non-scroll related events. I noticed that Karabiner seemed to intercept events earlier than Hammerspoon (for example, when trying to send Hammerspoon remapped keys to Keyboard Maestro, Keyboard Maestro would sometimes intercept the original key values, but when using Karabiner remapped keys, Keyboard Maestro would intercept the remapped values as expected). I have also created a script that makes it very easy to update the Karabiner config file. I will leave this branch as-is since it's a good resource for Hammerspoon users, but for my latest settings, check out the scroll-events-only branch.

My Hammerspoon Settings

My Hammerspoon configuration file sets up the following rules. See my init.lua file for more details.

The following keys get remapped so that they can be used for navigation:

  • leftCmd + iup
  • leftAlt + icmd + up (scroll to top of page)
  • leftCmd + kdown
  • leftAlt + kcmd + down (scroll to bottom of page)
  • leftCmd + jleft
  • leftCmd + ualt + left (left one word)
  • leftCmd + hcmd + left (jump to beginning of line)
  • leftCmd + lright
  • leftCmd + oalt + right (right one word)
  • leftCmd + ;cmd + right (jump to end of line)
  • leftCmd + 'cmd + right (jump to end of line)

I also map alt + scroll to scroll to the top or bottom of the page by multiplying the scroll distances by 1,000. This is better than just mapping to cmd + up/down because this allows you to scroll to the top/bottom of pages that are not in focus but are hovered over by the cursor:

  • alt + scroll upscroll up 1,000x (scroll to top of page)
  • alt + scroll downscroll down 1,000x (scroll to bottom of page)

And I use Mos to map cmd + scroll to scrolling in the same direction but faster:

  • cmd + scroll upscroll up faster
  • cmd + scroll downscroll down faster

The following hotkeys are enabled when my external keyboard is not connected:

  • `escape
  • cmd + ` `

Global hotkeys:

  • cmd + escape → Activate Brave and open a new tab. (Note: I have my caps lock key remapped to escape in System Preferences > Keyboard > Modifier Keys, so for me, this hotkey is really activated by cmd + caps lock)

Remapped browser hotkeys (for both Brave and Chrome):

  • cmd + 1alt + cmd + i (Toggle the developer tools)
  • cmd + 4cmd + ctrl + f (Toggle full screen mode)

Remapped Davinci Resolve events:

  • cmd + scrollalt + scroll (so that I can use cmd + scroll to zoom in an out of the timeline)

I also swap my middle and right mouse button events (I use an Evoluent vertical mouse, and the Evoluent mouse driver is currently broken in Big Sur, so I use Hammerspoon to remap the buttons instead). And I map the extra thumb buttons to swipe gestures:

  • rightMouseDownmiddleMouseDown
  • rightMouseUpmiddleMouseUp
  • rightMouseDraggedmiddleMouseDragged
  • middleMouseDownrightMouseDown
  • middleMouseUprightMouseUp
  • middleMouseDraggedrightMouseDragged
  • mouseButton4DownswipeLeft
  • mouseButton3DownswipeRight

My YouTube Video about Hammerspoon: https://youtu.be/wpVNm8Ub-1s

Note: If you are trying to map from one key to that same key with a different modifier (e.g. rightCmd + actrl + a), the default method I use in my code to setup the above mappings won't work, but you can use the workaround mentioned here: #1

License

MIT