Skip to main content
  1. Posts/

Mechanical Keyboard Set up For Mac

··445 words·3 mins·
Mac Keyboard
Table of Contents

Recently I bought a MacBook Pro 2018. While it is a good design overall, its built-in keyboard is not so great AFAIK. So I bought a mechanical keyboard ikbc c87. The mechanical keyboard is designed for the Windows operating systems. I have to make a few tweaks to make my typing experience smooth.

Before we begin
#

I have tested the below settings on my MacBook Pro 2018 with the latest Mojave system. For older Mac OS, it probably will work too. But I cannot say for sure.

Switch Win and Alt key
#

The Win and Alt keys in the mechanical keyboard correspond to command and option key in the Mac internal keyboard, respectively. But the positions of the two keys are slightly different. In order to make the keyboard work more like Mac internal keyboard, we can use Karabiner-Elements to switch the key mappings of Win and Alt.

After installing Karabiner-Elements, open its preference and choose Simple Modifications. Then, choose your external keyboard as Target Device. Click the Add item button to add one mapping. We need to add four mappings in total, i.e.,

From keyTo key
left_altleft_gui
left_guileft_alt
right_altright_gui
right_guiright_alt

The left_gui and right_gui keys are equal to left_command and right_command.

After this step, you may also consider changing the key caps of Win and Alt to make it clear you have switched the functions of Alt and Win.

Disable internal keyboard when external keyboard is connected
#

While using the external keyboard, you may want to disable the internal keyboard temporarily.

First, open Karabiner settings and go to Devices menu. In the bottom section, check the button of external USB keyboard to disable the built-in keyboard when external keyboard is connected.

Make Home and End key behave like Windows
#

On Mac, by default, if you press Home and End key, you will go to the beginning and end of current document, which is often not what you expect. We can make the behavior of Home and End key like Windows, i.e., go to the beginning and end of current line.

First, create a folder ~/Library/KeyBindings/ if it does not exist. Then create a file named DefaultKeyBinding.dict and add the following settings into it:

{
  "\UF729"  = moveToBeginningOfLine:; // home
  "\UF72B"  = moveToEndOfLine:; // end
  "$\UF729" = moveToBeginningOfLineAndModifySelection:; // shift-home
  "$\UF72B" = moveToEndOfLineAndModifySelection:; // shift-end
  "^\UF729" = moveToBeginningOfDocument:; // ctrl-home
  "^\UF72B" = moveToEndOfDocument:; // ctrl-end
  "^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; // ctrl-shift-home
  "^$\UF72B" = moveToEndOfDocumentAndModifySelection:; // ctrl-shift-end
}

Rebooting is needed. The change should take effect after system restart.

Now, happy typing!

References
#

Related

How to Extract PDF file on macOS
·147 words·1 min
Mac PDF
PATH Variable Changed inside Tmux on macOS?
·424 words·2 mins
Mac Shell Zsh Tmux
macOS Operation Not Permitted?
·200 words·1 min
Mac