私はUSキーボードのMacBook Proを使用しており、英数・かなキーとしてKarabiner-Elements荷より、左⌘キーを英数に、右⌘キーをかなに設定している。この設定だとVirtual Boxを利用するときに⌘キーを押すとバッククオート(`)が入力されてしまう。これを回避する方法を検索したが見つからなかったので競って異例やKarabiner-Elementsのリファレンスマニュアルを参考に設定ファイルを作成した。
設定ファイルの場所
Karabiner-Elementsの設定ファイルは下記ディレクトリに保存する。
~/.config/karabiner/assets/complex_modifications
設定ファイルの内容は下記のとおり。
bundle_identifiersはKarabiner-ElementsのEventViewerで確認した。
{
"title": "Virtual Box setting",
"rules": [
{
"description": "Disable ⌘ key on Virtual Box",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_command",
"modifiers": {
"optional": [
"any"
]
}
},
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^org\\.virtualbox\\.app\\.VirtualBoxVM$"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "right_command",
"modifiers": {
"optional": [
"any"
]
}
},
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^org\\.virtualbox\\.app\\.VirtualBoxVM$"
]
}
]
}
]
}
]
}
設定ファイルの読み込みと反映
ファイルを保存後、Karabiner-ElementsのPreferencesを開き、Complex modificationsタブを開き、Add ruleボタンを押して作成したルールを読み込む。読み込まれたルールは一番下に追加されるが⌘キーを英数・かなキーに変更する設定より下になり、機能しなくなるのでその設定よりも上に位置するように↑UPボタンを押して位置を変更する。

以上の設定でVirtual Box使用時に⌘キーを無効化できた。