Magic Keyboard => remap JKIL to arrows for Mac and PC
Tags: tutorial, tooling, developer, productivity
Published: 2024-03-02 22:56:25

As a developer, I really like the ergonomics and feel of Magic Keyboard combined with the 10 finger typing method. Before MacBook, I used Magic Keyboard with Numeric Keypad paired with a Windows laptop, where I swapped left <kbd>⌘command</kbd> with <kbd>⌃control</kbd> for a Mac-like copypasting. 

My current setup includes a company provided Windows laptop and a MacBook Pro M1 with [Microsoft Remote Desktop](https://learn.microsoft.com/en-us/windows-server/remote/remote-desktop-services/clients/remote-desktop-mac) client (RD) connecting to the corporate Windows workspace. 

When I started to use two different systems, I faced the following challenges.

**Challenge 1**

Since Mac's keyboard lacks the numeric pad and especially <kbd>delete</kbd> <kbd>home|end</kbd> <kbd>page up|down</kbd> keys which I was heavily dependant on, my typing productivity on Mac suffered a lot compared to using the full-scale keyboard.

The solution here could be to use the full-scale Magic Keyboard with Mac, but I didn't want to go this way.

**Challenge 2**

Both modifier keys and keyboard shortcuts on Mac and Windows are quite different. This challenge escalates with the use of RD which provides limited coverage of Mac's shortcuts (copypaste, undo, find and select all).

Here, without remapping of the keyboard keys to some sort of unified layout, productivity and speed will always suffer.

**Challenge 3**

<kbd>←</kbd><kbd>↓</kbd><kbd>↑</kbd><kbd>→</kbd> keys are naturally placed aside from the letter keys. With the touch typing, index fingers sit on <kbd>F</kbd> and <kbd>J</kbd> keys, and each time you need to move a cursor, you move your hand to reach the arrows keys or mouse or trackpad (alternatively with a thumb) and then back to <kbd>J</kbd>.

Again, with the full-scale keyboard, muscle memory was doing it great, but Mac's little arrow keys proved to be a challenge. 

**How I solved all these challenges**

1. I replaced external full-scale Magic Keyboard with a shorter version that is exactly the same as Mac's built-in keyboard. This one is used at work with the Windows laptop.

2. I use Mac's built-in Magic Keyboard.

3. <kbd>J</kbd><kbd>K</kbd><kbd>I</kbd><kbd>L</kbd> are mapped as <kbd>←</kbd><kbd>↓</kbd><kbd>↑</kbd><kbd>→</kbd>. Right <kbd>⌘command</kbd> is remapped to <kbd>⌃control</kbd>, and to use <kbd>J</kbd><kbd>K</kbd><kbd>I</kbd><kbd>L</kbd> as arrows, right thumb shall press and hold the new <kbd>⌃control</kbd>. To enable basic [document shortcuts](https://support.apple.com/en-us/HT201236), some other changes are also done in addition (ref. cover image on top). Left <kbd>⌘command</kbd> is remapped to <kbd>⌃control</kbd> on Windows only.

4. [Karabiner-Elements](https://karabiner-elements.pqrs.org) is installed on Mac to cover both Mac and RD, each having own remapping scope.

5. [AutoHotKey (AHK)](https://www.autohotkey.com) is installed on the Windows laptop. [PowerTools](https://learn.microsoft.com/en-us/windows/powertoys/) was tried first, but it had some inconsistencies and therefore replaced with AHK. Swap of 3 keys with registry is required in addition.

**Result**

I have now a seamless experience with Magic Keyboard on both macOS and Windows as if I work on one system.

All the details are to be provided in a future post...