Macの Windows App からWindowsマシンへリモートデスクトップ接続しているのですが、Apple純正JISキーボードを使うと、リモート先でキー配列がUS配列として扱われる問題に遭遇しました。
この手の問題の解決で、Windows Appの入力モードを「Unicode」にするというのをよく見かけるのですが、それだとIMEが挙動不審になる問題がありました。
そこで、最終的に
- Windows Appは Scancodeモード
- Karabiner-Elementsで Windows App使用時だけJIS記号キーをUS配列相当に変換
- 「英数」「かな」キーはどちらも Shift + Space に変換
という構成にすることで、かなり自然に使えるようになりました。
同じ症状で困っている方の参考になればと思い、設定をまとめます。
困っていた内容
Mac側ではApple純正の日本語JISキーボードを使用しています。
Windows AppからWindows 11へリモートデスクトップ接続すると、Windows側では
日本語キーボード (106/109キー)
になっているにもかかわらず、実際の入力はUS配列のような動作になっていました。
たとえばJISキーボードでは、
Shift + 2 → "
となるはずですが、リモート先では、
Shift + 2 → @
となります。
US配列では Shift + 2 = @ なので、Windows AppのScancode入力時にMac側JISキーボードがUS配列相当として扱われているようでした。
他に、IMEのON/OFFができない問題もあったのですが、こちらはIMEの設定にて
Shift + Space
をON/OFFに割り当てることで問題はなくなりました。
環境
今回の環境は以下です。
Mac
Apple Magic Keyboard - 日本語(JIS)
リモートデスクトップクライアント
Microsoft Windows App for macOS
接続先
Windows 11
Windows側キーボード設定
日本語キーボード (106/109キー)
IME
Microsoft IME
キーリマップ
Karabiner-Elements
Windows Appの入力モードは、最終的に
Scancode
を使用しています。
最初に確認したこと
Windows側で以下を確認しました。
設定
→ 時刻と言語
→ 言語と地域
→ 日本語
→ 言語のオプション
ハードウェアキーボードレイアウトは、
日本語キーボード (106/109キー)
になっていました。
それでもScancodeモードで、
Shift + 2
を押すと、
@
が入力されました。
この時点で、Windows側のキーボード設定というより、Windows App側でMacのJISキーボードがUS配列相当として扱われていると判断しました。
Unicodeモードも試した
Windows AppにはUnicode入力モードがあります。
こちらを使うと記号入力自体はかなり正常になります。
たとえば、
@
:
"
[
]
などがJIS配列どおりに入力できました。
ただし私の環境では、Unicodeモードにすると
Shift + Space
によるMicrosoft IMEの切り替えが使えなくなりました。
IMEのON/OFFを
Ctrl + Space
に変更すると切り替えできるようにはなるのですが、一文字づつ確定されてしまったり変換候補がとんでもない場所にでたり、IMEの挙動が全般的におかしくなります。
そのため、Unicodeモードは使わず、Scancodeモードを使うことにしました。
解決方法
最終的には、
Windows AppをScancodeモードのまま使い、Karabiner-ElementsでWindows App使用時だけJIS記号キーをUS配列相当のキー操作へ変換する
方法にしました。
考え方は以下です。
Apple JISキーボード
↓
Karabiner-Elements
↓
US配列で同じ文字になるキー操作へ変換
↓
Windows App(Scancode)
↓
Windows
たとえばApple JISキーボードの @ キーを押した場合、そのままWindows Appへ送るとUS配列の別キーとして認識されます。
そこでKarabiner側で、
JISの @
→ US配列の Shift + 2
へ変換します。
これにより、リモートWindows上では最終的に @ が入力されます。
Windows Appだけに適用する
Windows Appのbundle identifierは、
com.microsoft.rdc.macos
です。
Karabiner-Elementsの frontmost_application_if を使うことで、Windows Appが前面にある場合だけ変換できます。
そのため、通常のmacOS操作には影響しません。
「英数」「かな」キーについて
今回はApple純正JISキーボードの
英数
かな
も使えるようにしました。
どちらも、
Shift + Space
へ変換しています。
Windows側では Shift + Space をIME切り替えとして使っているため、
英数 → Shift + Space
かな → Shift + Space
というトグル動作にしています。
macOSの動作とは違いますが、Windowsでは「全角/半角」キーがトグルなのは普通の動作なので許容しました。
Karabiner-Elements の設定
以下が実際に使用している設定です。
Windows Appは Scancodeモード にして使用します。
Karabiner-Elementsはこちらからインストールしてください。
Karabiner-Elementsを起動し、「Complex Modifications」-「Add your own rule」に以下をコピペしてください。
{
"description": "Windows App: Apple JIS -> US scancode symbols + Eisu/Kana to Shift+Space",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "japanese_eisuu",
"modifiers": {
"optional": ["any"]
}
},
"to": [
{
"key_code": "spacebar",
"modifiers": ["left_shift"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "japanese_kana",
"modifiers": {
"optional": ["any"]
}
},
"to": [
{
"key_code": "spacebar",
"modifiers": ["left_shift"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "2",
"modifiers": {
"mandatory": ["shift"],
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "quote",
"modifiers": ["left_shift"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "6",
"modifiers": {
"mandatory": ["shift"],
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "7",
"modifiers": ["left_shift"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "7",
"modifiers": {
"mandatory": ["shift"],
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "quote"
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "8",
"modifiers": {
"mandatory": ["shift"],
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "9",
"modifiers": ["left_shift"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "9",
"modifiers": {
"mandatory": ["shift"],
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "0",
"modifiers": ["left_shift"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "hyphen",
"modifiers": {
"mandatory": ["shift"],
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "equal_sign"
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "equal_sign",
"modifiers": {
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "6",
"modifiers": ["left_shift"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "equal_sign",
"modifiers": {
"mandatory": ["shift"],
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "grave_accent_and_tilde",
"modifiers": ["left_shift"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "open_bracket",
"modifiers": {
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "2",
"modifiers": ["left_shift"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "open_bracket",
"modifiers": {
"mandatory": ["shift"],
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "grave_accent_and_tilde"
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "close_bracket",
"modifiers": {
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "open_bracket"
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "close_bracket",
"modifiers": {
"mandatory": ["shift"],
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "open_bracket",
"modifiers": ["left_shift"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "semicolon",
"modifiers": {
"mandatory": ["shift"],
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "equal_sign",
"modifiers": ["left_shift"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "quote",
"modifiers": {
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "semicolon",
"modifiers": ["left_shift"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "quote",
"modifiers": {
"mandatory": ["shift"],
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "8",
"modifiers": ["left_shift"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "backslash",
"modifiers": {
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "close_bracket"
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "backslash",
"modifiers": {
"mandatory": ["shift"],
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "close_bracket",
"modifiers": ["left_shift"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "international3",
"modifiers": {
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "backslash"
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "international3",
"modifiers": {
"mandatory": ["shift"],
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "backslash",
"modifiers": ["left_shift"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "international1",
"modifiers": {
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "backslash"
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
},
{
"type": "basic",
"from": {
"key_code": "international1",
"modifiers": {
"mandatory": ["shift"],
"optional": ["caps_lock"]
}
},
"to": [
{
"key_code": "hyphen",
"modifiers": ["left_shift"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.rdc\\.macos$"
]
},
{
"type": "keyboard_type_if",
"keyboard_types": ["jis"]
}
]
}
]
}
この設定で変わる主なキー
代表的なものは以下です。
| Apple JISで押すキー | Windows側で期待する文字 |
|---|---|
Shift + 2 |
" |
Shift + 6 |
& |
Shift + 7 |
' |
Shift + 8 |
( |
Shift + 9 |
) |
Shift + - |
= |
^ |
^ |
Shift + ^ |
~ |
@ |
@ |
Shift + @ |
` |
[ |
[ |
Shift + [ |
{ |
; |
; |
Shift + ; |
+ |
: |
: |
Shift + : |
* |
] |
] |
Shift + ] |
} |
¥ 系キー |
\ |
Shift + ¥ |
` |
| 「ろ」側キー + Shift | _ |
, <、. >、/ ?、1 !、3 #、4 $、5 % などはUS配列と同じなので変換していません。
KarabinerでJIS記号キーの名前が分かりにくい
Karabiner-Elementsでは、JISキーボードの物理キーと key_code 名が直感的に一致しないものがあります。
たとえば、
JISの @ キー
→ open_bracket
JISの [ キー
→ close_bracket
JISの ] キー
→ backslash
JISの ¥ 系キー
→ international3
JISの「ろ」側キー
→ international1
のようになります。
設定が合わない場合は、Karabiner-EventViewerで実際にキーを押して、どの key_code が出ているか確認すると分かりやすいです。
最終的な構成
最終的には以下の構成になりました。
Mac
└─ Apple Magic Keyboard - 日本語(JIS)
↓
Karabiner-Elements
├─ JIS記号をUS配列相当へ変換
├─ 英数 → Shift + Space
└─ かな → Shift + Space
↓
Windows App
└─ Scancodeモード
↓
Windows 11
└─ Microsoft IME
Windows App以外ではKarabinerの変換条件に一致しないため、普通のMac用JISキーボードとして動作します。
まとめ
今回の問題では、Windows側を
日本語キーボード (106/109キー)
にしても、Windows AppのScancodeモードではUS配列相当になってしまいました。
Unicodeモードにすると記号入力は正常になるものの、自分の環境では Shift + Space によるIME切り替えが使えず、IME自体も挙動不審でした。
そこで、
Windows AppはScancode
+
Karabiner-ElementsでJIS→US相当変換
という方法にしました。
結果として、
- JISキーボードの印字に近い記号入力
- Scancodeモードの利用
-
Shift + SpaceによるIME切り替え - 「英数」「かな」キーからIME切り替え
- Windows App以外には影響しない
という状態にできました。
同じように、
MacからWindows AppでRDPすると、JISキーボードなのにUS配列になってしまう
という症状で困っている場合には、一つの回避策になると思います。