Mapping your macOS keybinds to Windows

Maybe Brad Frost’s horror story about the new MacBook Pro worried you or maybe #davegoeswindows convinced you — but, long story short, you bit the bullet and went Windows. Hopefully, you found Owen William’s great post to setting up your perfect Windows developer environment, but there’s just… just one thing that’s bothering you.

Who in the world wants to use their pinky finger to use their main modifier key? The Control button is so far away! The Command button placement was perfect! Not to worry, with a combination of Sharp Keys and AutoHotkey you can simulate the same keyboard environment as you’re used to.

TL;DR

  1. Use Sharp Keys to remap Ctrl and Alt
  2. Use AutoHotkey + this starter script to bring over basic macOS keyboard bindings and restore Alt Tab functionality.

Step One: Sharp Keys

Sharp Keys is going to be used to swap the Ctrl and Alt keys on your Windows keyboard.

  1. Download, install, and run Sharp Keys
  2. Hit the ‘Add’ button, you’ll see two columns — one that indicates the button you hit, the other that shows the action you want to take. Scroll to find the Special: Left Alt on the left column and select it. On the right column, scroll to find the Special: Left Ctrl and select it. The screen should look like this

3. Hit OK, and then do the same for reverse action. You’ll end up with a screen that looks like this.

4. Press Write to Registry and reboot; Alt now maps to Ctrl and vice versa, almost like what happens in macOS!

AutoHotkey

Unfortunately that alone isn’t quite perfect, in macOS we use Command + Tab to tab through active windows and Ctrl + Tab to tab through browser windows; that’s the default scenario on Windows as well, but we just reversed it. Thankfully, AutoHotKey can intercept button presses and execute different actions.

  1. Download and install AutoHotkey. AutoHotkey is an automation scripting language — which means nothing actually happens until we create and run a script. Let’s do that now.
  2. Open the Start Menu in the lower left corner and open the Run dialog. To get to it quickly, simply press Windows + R. Type in shell:startup and hit enter to open up Windows Explorer in the Startup folder. Any script we create here will run on Startup.
  3. Create a new AutoHotKey script by opening the context menu in the folder (right click), press New, and then press AutoHotkey script. You can also create a new blank new file here and save it with a .ahk extension.

4. Copy and paste this starter script into your file. https://gist.github.com/chrisdhanaraj/f6d1ff1e27e733bdd43257506688ccfc. Save, exit, and run the script.

The trick with AutoHotkey is that, now that you’ve mapped Ctrl to Alt and Alt to Ctrl, any script you write has to function with that in mind. This script brings a couple things over.

  • Alt + Tab is once again rebound to toggle through active Windows, and Ctrl + Tab returns to tab through browser windows.
  • Alt + Up/Down maps to the Home and End keys on Windows to mimic the document scroll manipulation that macOS has. Similarly, Alt + Left/Right brings you to the end and beginning of lines, and all four directional sets function with Shift in mind to select things.
  • Alt + Space opens the Start Menu to mimic Spotlight (the Windows start menu functions pretty much identically to Spotlight now).

And that’s it! There are still a bunch more macOS keyboard bindings that I have yet to bring in, but these are the major ones for me. I use VS Code on Windows (as well as on macOS), and I’ve yet to run into any keyboard bindings that have tripped me up once I’ve done these couple of tweaks.

Questions or improvements? Contact me @chrisdhanaraj on Twitter or leave a comment below.