How to use Windows keymap on Mac and in your favorite IDE for example IntelliJ?

Viktor Reinok
5 min readJun 20, 2021

--

Why? An example would be working on a multi-platform system where one needs to deal with Linux, Windows, and Mac. Having a common hotkey mapping will remove the friction; get the edge on efficiency; reduce the learning curve and use more ergonomic tooling interfaces across platforms.

There are the following problems out of the box:

1. Mac keyboard shortcuts or hotkeys are different compared to Windows
1.1 Control (Win) aka. Command (Mac) is not on the bottom right edge.
1.2 There is a third key on Mac. Ctrl, Alt vs Control, Option, Command
1.3 Mac keyboard shortcuts vs. Windows. Alt-Tab, Other

Indeed, due to Windows and Mac shortcuts differences, the IntelliJ keymap on Mac is also different.

2. IDE such as IntelliJ Mac hotkey is very different
2.1 How to find Windows keymap in IntelliJ on Mac?
2.2 How to solve the problem with the Karabiner elements?
2.3 Conflicting keymaps with Mac internal shortcuts

1.1 Changing keymapping on Mac

Many most used commands in Windows and Linux rely on the key on the bottom right edge: The Crtl key. Therefore pinky copy-paste.

Mac’s default thump copy-paste is used: command + c. etc.

Easy! Just change the mapping from Mac Preferences. It could vary across the versions but for v13+ would work as follows.

System Preferences ->
Keyboard ->
Keyboard shortcuts ->
Modifier keys ->
Select Keyboard

Whoila! You got your pinky copy instead of a thump copy. Something You would use out of the box on the Win and Linux systems.

1.2 On the Mac there is one more modifier key.

It is used across the OS. On Windows, the keyboard is usually replaced by the Windows key that opens the program search. I believe it is the very reason why the IDE key mapping is different across the platforms.

1.3 Mac keyboard shortcuts vs. Windows

Alt-Tab

For that one could use a free tool called AltTab [6]

Other Mac keyboard shortcuts

Kabiner (mentioned below) offers “PC-style shortcuts” that replace most of the shortcuts to Windows alike [5]

Still, some do not work like switching a language. So, for me, it is still Alt + Space. Or Command + Space

2.1 How to find a Windows keymapping in Intellij?

Obviously, IntelliJ provides several choices. However one would not be able to find a keymap that provides the same Windows keymap experience.

One could find the XWin keymap under the plugin marketplace search. [4]

Problem with IntelliJ’s XWin keymap on Mac

2.1.a The familiar Ctrl key is not on the right bottom corner as We have swapped copy-paste in the Mac to have a pinky copy-paste.

How can we do that? We can go to the keymap editor in the IDE and change every key with control to meta. It will take forever. Can we change the config file in the file system? Find-replace for example? Here is how we are able to do it:

We can fix this by replacing control with meta in the XWin keymap
https://gist.github.com/vikreinok/69e18a79d08db956db4b56a9ae2feb91

Now, where we can find the keymap config file in Mac?

How to change the file manually:
First, we use a local repository to store the settings.
File → Manage IDE Settings → Settings repository

When you copy the XWin keymap, you will give it your name. XWin copy for example. Where are you able to find this custom copy?
/Users/username/Library/Application Support/JetBrains/IntelliJIdea2021.1/settingsRepository/repository/keymaps

2.1.b The Familiar Alt key is not leftmost to the Space key.

Check out point 1.1 in this article which describes how to remap keys on a Mac

2.2 Alt + any other key produces as a symbol.

So, the leftmost… The closest key to space with a combination of many other keys produces a symbol. Something you might have experienced on Windows with Alt Gr + number on the keypad for example. Now, why it is a problem? It conflicts with the most used IntelliJ key mappings on Mac.

2.2.a To counter that we need to install Karabiner elements

https://karabiner-elements.pqrs.org/docs/getting-started/installation/

2.2.b Edit a rule file [2]
/Users/username/.config/karabiner/karabiner.json and added your own rule in that JSON under:
profiles > complex_modifications > rules:

{
"description": "ctrl/command swap",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.jetbrains\\.intellij$"
],
"type": "frontmost_application_unless"
}
],
"from": {
"key_code": "left_control"
},
"to": [
{
"key_code": "left_command"
}
],
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.jetbrains\\.intellij$"
],
"type": "frontmost_application_unless"
}
],
"from": {
"key_code": "left_command"
},
"to": [
{
"key_code": "left_control"
}
],
"type": "basic"
}
]
}

2.3 Conflicting keymaps with Mac and how to fix them

Of course, as you might expect there are some side effects when using your own super customized keyset. Some IDEA keys conflict with the following MAC key shortcuts:

  • Quit program (control + q)
    In IDEA it is showing
  • Show hierarchy (control + h)
    It hides the window

Summary

Using those steps I was able to achieve very similar keyboard shortcut mappings as on Windows on the latest Mac OS X. It took me a good day to get the hang of all the differences. That said, I believe you are in luck as you have landed on this very article with a similar problem in hand. Now, it should take no more than 15 minutes to apply all the described modifications. In case of questions or any caveats that you might want to add, please feel free to comment underneath or reach me on other channels.

References:

  1. https://stackoverflow.com/questions/35874608/intellij-default-windows-keymap-on-mac-os-x
  2. https://resources.jetbrains.com/storage/products/intellij-idea/docs/IntelliJIDEA_ReferenceCard.pdf
  3. https://gist.github.com/vikreinok/69e18a79d08db956db4b56a9ae2feb91
  4. https://plugins.jetbrains.com/plugin/13094-xwin-keymap
  5. https://apple.stackexchange.com/questions/312656/how-can-i-reprogram-osx-to-use-windows-style-shortcuts-for-all-operations
  6. https://alt-tab-macos.netlify.app/

--

--

Viktor Reinok
Viktor Reinok

Responses (1)