MacOS – Globally move mouse pointer and click using VIM keystrokes

accessibilitykeyboardmacosmouse

I'd like to be able to hit a hot key, and enter a mouse movement mode where I can move the mouse pointer around the screen using VIM keystrokes – regardless of the app I'm in (ie globally for all apps)

For example, just say my mouse mode key was SHIFT+COMMAND+M

  • I hit SHIFT+COMMAND+M to enter mouse mode
  • I use h,j,k,l to move the cursor around the screen, and possibly some other keys to jump from monitor to monitor
  • I hit the enter key to click, and leave mouse mode, or hit esc to exit mouse mode.

Are there any apps out there that would let me do this? I'm aware of "Mouse Keys", but I really want to be able to customize:

  • the keys I use to move around
  • the amount of movement that's done by the mouse when a key is pressed.

Best Answer

A tool that might just help you is Cliclick. With it, you can read the mouse position using the p:. command, move the mouse using the m:x,y command, and click using the c:. command.

This is a bit of a hack, really, but regarding the multi-monitor support, you can use Slate, where you can programmatically call Cliclick with the coordinates of the mouse in a different monitor. I'm sure there are other alternatives, though. I also used Slate to bind the other first calls to Cliclick.

The "mouse mode" is a bit tougher. In Slate you can create "modal hotkeys" pressing two hotkeys in succession (like ^W in Vim), but no support for whole modes. You could, however, dynamically edit the .slate.js binding file to contain "normal mode" or "mouse mode" bindings each time you change the mode.

I did something similar yesterday, so hope this helps. :)