LoginSignup
31
23

More than 1 year has passed since last update.

Macの挙動を限りなくWindowsに近づける

Last updated at Posted at 2022-05-11

やりたいこと

Macに外付けキーボードを繋いで使っており,Windowsと同じ操作感になることを目指します.
キーボードはJIS配列前提で書いています.

Google日本語入力

Google製のIMEです.
標準のIMEよりもMS-IMEに挙動が近いためこちらを使用します.

キーボードの入力ソースをGoogle日本語入力の英数とひらがなのみにしてしまうのがおすすめです.
そのままでは元の入力ソースが残ってしまうため,こちらのサイトで紹介されているように,日本語の入力モードで英数にチェックを入れたうえで不必要なものを全て消しましょう.

また,環境設定→一般→キー設定の選択を「MS-IME」にすることでWindowsのキーマッピングになります.

Karabiner-Element

キーボードやマウスの動作を変更することができるカスタマイズアプリです.
アプリごとにショートカットキーの設定が可能なので,細かい動作をWindowsに近づけられます.

キー名やアプリ名が知りたい時,うまくマッピングできたか確認したい際は一緒にインストールされるKarabiner-EventViewerが便利です.

インストール後の初期設定

私の環境ではキーボードがUS配列になってしまったためまず対処しました.
調べるとDevicesでApple Internal Keyboard/Trackpadのチェックを外すや,Virtual KeyboardのCountry Codeを45にするといった対処法が出てきますが,この方法ではJIS配列にすることができませんでした.
結果的には,Karabiner-Elementsのこちらのissueに書かれているように,Virtual KeyboardのCountry Codeを1にすることで解決しました.
以上の方法で解決しない時はKarabiner-Elementsのissueを探してみることをおすすめします.

Simple modificaton

1対1のキーマッピングの設定です.
Target deviceが「For all devices」だと内蔵キーボードも変更されるため,変更したいキーボードを選択します.

CommandキーとControlキーの入れ替え

left_command  → left_control
left_control  → left_command
right_command → right_control
right_control → right_command

半角/全角キーで入力ソースの切り替え

まずシステム環境設定→キーボード→ショートカット→入力ソースの「前の入力ソースを選択」をF13に変更します.
その上で,半角/全角キーを押すとF13として入力されるように設定します.

grave_accent_and_tilde (`) → f13

無変換キーでカタカナ変換

Google日本語入力でキー設定をMS-IMEにしている場合カタカナ変換がF7になるため,無変換キーを押した際にF7として入力されるように設定します.

PCキーボードの無変換キー → f7

Complex modifications

複雑なキーマッピングの設定です.
~/.config/karabiner/assets/complex_modificationsにjsonファイルを置くと,Complex modificationsのAdd ruleに表示されるようになります.
アプリを終了させなくても反映されるため,もし出てこない場合はカッコの対応が間違っていないかや余分なカンマがないかなどを確認してみると良いでしょう.

Homeキー,Endキーの設定

HomeキーをCommand+←,EndキーをCommand+→に割り当てます.
Shiftキーを押しながら選択できるように,optionalにanyを指定しています.

home_and_end.json
{
  "title": "HomeキーとEndキー",
  "rules": [
    {
      "description": "HomeキーをCommand+←にする",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "home",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": {
            "key_code": "left_arrow",
            "modifiers": [
              "command"
            ]
          }
        }
      ]
    },
    {
      "description": "EndキーをCommand+→にする",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "end",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": {
            "key_code": "right_arrow",
            "modifiers": [
              "command"
            ]
          }
        }
      ]
    }
  ]
}

Homeキー,Endキーの設定(Terminal)

Terminalでは挙動が違うため,行頭・行末に移動するショートカットキーであるControl+A, Control+Eを割り当てます.
設定したルールは上から一致したものが適用されるため,上のHomeキー,Endキーの設定より上に置く必要があります(ウィンドウ右下のUp, Downボタンより).

terminal_home_and_end.json
{
  "title": "[Terminal]HomeキーとEndキー",
  "rules": [
    {
      "description": "[Terminal]HomeキーをControl+←Aにする",
      "manipulators": [
        {
          "type": "basic",
          "conditions": [
            {
              "type": "frontmost_application_if",
              "bundle_identifiers": [
                  "^com.apple.Terminal"
              ]
            }
          ],
          "from": {
            "key_code": "home",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": {
            "key_code": "a",
            "modifiers": [
              "control"
            ]
          }
        }
      ]
    },
    {
      "description": "[Terminal]EndキーをControl+Eにする",
      "manipulators": [
        {
          "type": "basic",
          "conditions": [
            {
              "type": "frontmost_application_if",
              "bundle_identifiers": [
                  "^com.apple.Terminal"
              ]
            }
          ],
          "from": {
            "key_code": "end",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": {
            "key_code": "e",
            "modifiers": [
              "control"
            ]
          }
        }
      ]
    }
  ]
}

Commandキーで単語ごと移動

元々Option+←,Option+→で単語ごと移動できますが,それをCommandキーでできるようにします.

command_option_leftright.json
{
  "title": "Coomandキーで単語ごと移動",
  "rules": [
    {
      "description": "Command+←をOption+←にする",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "left_arrow",
            "modifiers": {
              "mandatory": [
                "command"
              ],
              "optional": [
                "command",
                "shift"
              ]
            }
          },
          "to": {
            "key_code": "left_arrow",
            "modifiers": [
              "option"
            ]
          }
        }
      ]
    },
    {
      "description": "Command+→をOption+→にする",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "right_arrow",
            "modifiers": {
              "mandatory": [
                "command"
              ],
              "optional": [
                "command",
                "shift"
              ]
            }
          },
          "to": {
            "key_code": "right_arrow",
            "modifiers": [
              "option"
            ]
          }
        }
      ]
    }
  ]
}

Optionキーで行頭・行末に移動

Commandキーで単語ごと移動できるように設定するとHomeキー・Endキーのないキーボードでは行頭・行末に移動できなくなるためOptionキーに割り当てます.

option_command_leftright.json
{
  "title": "Optionキーで行頭・行末に移動",
  "rules": [
    {
      "description": "Option+←をCommand+←にする",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "left_arrow",
            "modifiers": {
              "mandatory": [
                "option"
              ],
              "optional": [
                "option",
                "shift"
              ]
            }
          },
          "to": {
            "key_code": "left_arrow",
            "modifiers": [
              "command"
            ]
          }
        }
      ]
    },
    {
      "description": "Option+→をCommand+→にする",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "right_arrow",
            "modifiers": {
              "mandatory": [
                "option"
              ],
              "optional": [
                "option",
                "shift"
              ]
            }
          },
          "to": {
            "key_code": "right_arrow",
            "modifiers": [
              "command"
            ]
          }
        }
      ]
    }
  ]
}

バックスラッシュ(\)を右Shiftキーの隣に

Macでは右Shiftキーの隣はShiftを押しても押さなくてもアンダースコア(_)が入力されますが,Windows同様Shiftキーを押さない場合はバックスラッシュ(\)が入力されるようにします.

underscore.json
{
  "title": "_をAlt+¥にする",
  "rules": [
    {
      "description": "_をAlt+¥にする",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "international1"
          },
          "to": {
            "key_code": "international3",
            "modifiers": [
              "option"
            ]
          }
        }
      ]
    }
  ]
}

F5キーでページ更新(ブラウザ)

ブラウザのみF5キーにCommand+Rを割り当てることでページ更新できるようにします.
ここではSafari, Google Chrome, Microsoft Edgeを指定していますが,適宜bundle_identifiersに使用しているブラウザの名前を指定してください.
名前はKanabiner-EventViewerのFrontmost Applicationで確認できます.

browser_f5.json
{
  "title": "[ブラウザ]F5キーでページ更新",
  "rules": [
    {
      "description": "[ブラウザ]F5キーでページ更新",
      "manipulators": [
        {
          "type": "basic",
          "conditions": [
              {
                  "type": "frontmost_application_if",
                  "bundle_identifiers": [
                      "^com.apple.Safari",
                      "^com.google.Chrome",
                      "^com.microsoft.edgemac"
                  ]
              }
          ],
          "from": {
            "key_code": "f5"
          },
          "to": {
            "key_code": "r",
            "modifiers": [
              "command"
            ]
          }
        }
      ]
    }
  ]
}

Command + Tab,Command + Shift + Tabでタブ切り替え(ブラウザ)

ブラウザのみCommannd+TabにCommand+Option+→,Command+Shift+TabにCommand+Option+←を割り当てることでタブ切り替えできるようにします.

browser_command_tab.json
{
  "title": "[ブラウザ]Command+Tab, Command+Shift+Tabでタブ切り替え",
  "rules": [
    {
      "description": "[ブラウザ]Command+Tabでタブ切り替え",
      "manipulators": [
        {
          "type": "basic",
          "conditions": [
              {
                  "type": "frontmost_application_if",
                  "bundle_identifiers": [
                      "^com.apple.Safari",
                      "^com.google.Chrome",
                      "^com.microsoft.edgemac"
                  ]
              }
          ],
          "from": {
            "key_code": "tab",
            "modifiers": {
              "mandatory": [
                "command"
              ],
              "optional": [
                "command"
              ]
            }
          },
          "to": {
            "key_code": "right_arrow",
            "modifiers": [
              "command",
              "option"
            ]
          }
        }
      ]
    },
    {
      "description": "[ブラウザ]Command+Shift+Tabでタブ切り替え",
      "manipulators": [
        {
          "type": "basic",
          "conditions": [
              {
                  "type": "frontmost_application_if",
                  "bundle_identifiers": [
                      "^com.apple.Safari",
                      "^com.google.Chrome",
                      "^com.microsoft.edgemac"
                  ]
              }
          ],
          "from": {
            "key_code": "tab",
            "modifiers": {
              "mandatory": [
                "command",
                "shift"
              ],
              "optional": [
                "command"
              ]
            }
          },
          "to": {
            "key_code": "left_arrow",
            "modifiers": [
              "command",
              "option"
            ]
          }
        }
      ]
    }
  ]
}

F2キーで名前の変更(Finder)

FinderのみF2キーにEnterキーを割り当てることで名前の変更をできるようにします.

finder_f2.json
{
  "title": "[Finder]F2キーで名前の変更",
  "rules": [
    {
      "description": "[Finder]F2キーで名前の変更",
      "manipulators": [
        {
          "type": "basic",
          "conditions": [
              {
                  "type": "frontmost_application_if",
                  "bundle_identifiers": [
                      "^com.apple.finder"
                  ]
              }
          ],
          "from": {
            "key_code": "f2"
          },
          "to": {
            "key_code": "return_or_enter"
          }
        }
      ]
    }
  ]
}

Enterキーでファイルを開く(Finder)

FinderのみEnterキーにCommnad+Oを割り当てることでファイルを開けるようにします.
Enterキーに割り当てることで,名前の変更時に確定するためにEnterキーを押すとファイルが開いてしまうという問題がありますが,そこまで困ることはないかと思います.

finder_enter.json
{
  "title": "[Finder]Enterキーでファイルを開く",
  "rules": [
    {
      "description": "[Finder]Enterキーでファイルを開く",
      "manipulators": [
        {
          "type": "basic",
          "conditions": [
              {
                  "type": "frontmost_application_if",
                  "bundle_identifiers": [
                      "^com.apple.finder"
                  ]
              }
          ],
          "from": {
            "key_code": "return_or_enter"
          },
          "to": {
            "key_code": "o",
            "modifiers": [
              "command"
            ]
          }
        }
      ]
    }
  ]
}

マウスの戻る・進むボタンで戻る・進む(Finder,システム環境設定)

Finderとシステム環境設定のみマウスの戻る・進むボタン(button4, button5)をCommand+[, Command+]に割り当てることで,マウスの戻る・進むボタンが使えるようにします.
他にもこのショートカットキーが使えるアプリでは設定すると便利だと思います.
設定のDevicesで使用しているマウスにチェックが入っていないと動作しないので注意が必要です.

mouse_button4_button5.json
{
  "title": "マウスの戻る・進むボタンで戻る・進む",
  "rules": [
    {
      "description": "マウスの戻るボタン(button4)で戻る",
      "manipulators": [
        {
          "type": "basic",
          "conditions": [
              {
                  "type": "frontmost_application_if",
                  "bundle_identifiers": [
                      "^com.apple.finder",
                      "^com.apple.systempreferences"
                  ]
              }
          ],
          "from": {
            "pointing_button": "button4"
          },
          "to": {
            "key_code": "close_bracket",
            "modifiers": [
              "command"
            ]
          }
        }
      ]
    },
    {
      "description": "マウスの進むボタン(button5)で進む",
      "manipulators": [
        {
          "type": "basic",
          "conditions": [
              {
                  "type": "frontmost_application_if",
                  "bundle_identifiers": [
                      "^com.apple.finder",
                      "^com.apple.systempreferences"
                  ]
              }
          ],
          "from": {
            "pointing_button": "button5"
          },
          "to": {
            "key_code": "non_us_pound",
            "modifiers": [
              "command"
            ]
          }
        }
      ]
    }
  ]
}

システム環境設定のショートカットキー設定

Mission Control

Mission Control:Control+↑ → Control+Tab
アプリケーションウィンドウ:Control+↓ → 「チェックを外す」
左の操作スペースに移動:Control+← → Control+Command+←
右の操作スペースに移動:Control+→ → Control+Command+→

Win+Tabでのウィンドウ表示,Ctrl+Win+→[←]での仮想デスクトップ切り替えに対応させています.

スクリーンショット

選択部分のピクチャをファイルとして保存:Shift+Command+3 → Control+Shift+S
選択部分のピクチャをクリップボードにコピー:Control+Shift+Command+3 → Command+Control+Shift+S

Win+Shift+Sでのスクリーンショット撮影に対応させています.
Windowsではファイル保存ではなくクリップボードへのコピーですが,両方の操作を可能にするためにCtrlキーを追加したキーバインドをクリップボードへのコピーにしています.

Finder

いくつか設定をして使いやすくします.

隠しファイルの表示

ショートカットキー(Commnad+Shift+.)で表示することはできますが,これだと常に表示はされません.
常に表示しておくようにするには以下のコマンドをターミナルで実行します.

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

サイドバーのカスタマイズ

環境設定のサイドバーからカスタマイズができます.
ハードディスクにチェックを入れることでMacintosh HD(ルートディレクトリ),ユーザ名にチェックを入れることでホームディレクトリが表示できます.
他にも使いそうなものにはチェックをいれておくと便利です.
Windows同様,フォルダのドラッグでピン留めも可能です.

右クリックで新規テキストの作成

こちらのサイトを参考にさせていただき設定しました.

スクリーンショットの保存先変更

Finderとは少し違いますが,ここに書いておきます.
Command+Shift+5でスクリーンショット収録のオプションを開くことができるので,オプションから任意のフォルダを指定します.

Scroll Reverser

マウスホイールの向きを逆にすることができるアプリです.
また,バージョン1.8.1でホイールスクロールのステップサイズ調整が追加されたため,Mac特有のスクロールの際の加速度を止めることができます.

AltTab

Alt + Tab(Option + Tab)でウィンドウを切り替えられるようにするアプリです.

環境設定→外観→テーマをmacOSからWindows10に変更すると,より見た目をWindowsに近づけることができます.
また環境設定→コントロール→次の機能を使い,ウィンドウを選択のマウスホバーのチェックを外すとよりWindowsでの使い勝手に近づきます.

Rectangle

マウスやショートカットキーでウィンドウ分割を行えるようにするアプリです.

Windowsのショートカットキーと合わせるため,以下の通り変更して使用しています.

Clipy

クリップボードを使えるようにするアプリです.

Win + Vでクリップボードが開けるようにショートカットキーの変更と,内容が分かりやすくなるように「メニューに表示する文字数」を40文字に変更して使用しています.

Microsoft Edge

言わずと知れたMicrosoftのブラウザです.
垂直タブが便利なのでGoogle Chromeと併用しています.

参考サイト

31
23
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
31
23