はじめに
英数キー(Eisu)を押している間だけ ESDF
などのキーを、矢印キーや編集キー、修飾キーとして使える機能をご紹介します。
macOSでは、Karabiner-Elementsを使って英数キーを“レイヤーキー”として再利用することで、手をほとんど動かさずにカーソル移動や文字編集が可能になります。
Windows版はこちらの記事からどうぞ → CapsLockが最強レイヤーキーに変身!ホームポジション崩さずVimライクに爆速タイピング
Karabiner-Elementsの導入・基本操作
Karabiner-Elementsのインストール方法や基本的な使い方は、以下の記事がわかりやすいです。
英数キーをレイヤーキーにする設定手順
- Karabiner-Elements を開く
- Complex Modifications タブを選択
- Add your own rule ボタンを押す
- 表示されたウィンドウ内にあるJSONのテンプレートをすべて削除し、この記事で紹介しているJSON全文をペースト
- save をクリックしてルールを有効化
これで「英数キーを押している間だけ」レイヤーが動作するようになります。
キーマップ変更用JSONの解説
- from:英数キー押下をトリガー
- to / to_after_key_up:押下時/離上時に変数を切り替え
- to_if_alone:単押し時は元のキー動作
- conditions:eisu_layer == 1 の場合のみマッピングを適用
{
"from": {
"key_code": "japanese_eisuu",
"modifiers": { "optional": ["any"] }
},
"to": [
{ "set_variable": { "name": "eisu_layer", "value": 1 } }
],
"to_after_key_up": [
{ "set_variable": { "name": "eisu_layer", "value": 0 } }
],
"to_if_alone": [{ "key_code": "japanese_eisuu" }],
"type": "basic"
}
このトリガー定義で変数を操作した後、同様のconditionsを使って各キーをマッピングします。
マッピング一覧表
元キー | 置換先機能 |
---|---|
E | ↑ (up_arrow) |
S | ← (left_arrow) |
D | ↓ (down_arrow) |
F | → (right_arrow) |
W | Backspace |
R | Enter |
T | Delete Forward |
X | Home |
V | End |
A | Tab |
N | ⌘ (right_command) |
H | ⌥ (right_option) |
M | ⌃ (right_control) |
※必要に応じて他のキーや修飾キーも自由に追加可能です。
コード全文
以下が、英数キーを押している間だけレイヤーを有効化し、ESDF〜WR…XVを矢印キーや編集キー、修飾キーにマッピングするKarabiner-Elementsの設定例です。rulesセクションに丸ごと貼り付けてください。
{
"title": "英数キーレイヤー(ESDF → 矢印等)",
"rules": [
{
"description": "While holding 英数 (Eisu), map ESDF and WR...XV",
"manipulators": [
{
"from": {
"key_code": "japanese_eisuu",
"modifiers": { "optional": ["any"] }
},
"to": [
{ "set_variable": { "name": "eisu_layer", "value": 1 } }
],
"to_after_key_up": [
{ "set_variable": { "name": "eisu_layer", "value": 0 } }
],
"to_if_alone": [{ "key_code": "japanese_eisuu" }],
"type": "basic"
},
{
"conditions": [
{ "type": "variable_if", "name": "eisu_layer", "value": 1 }
],
"from": { "key_code": "e", "modifiers": { "optional": ["any"] } },
"to": [{ "key_code": "up_arrow" }],
"type": "basic"
},
{
"conditions": [
{ "type": "variable_if", "name": "eisu_layer", "value": 1 }
],
"from": { "key_code": "s", "modifiers": { "optional": ["any"] } },
"to": [{ "key_code": "left_arrow" }],
"type": "basic"
},
{
"conditions": [
{ "type": "variable_if", "name": "eisu_layer", "value": 1 }
],
"from": { "key_code": "d", "modifiers": { "optional": ["any"] } },
"to": [{ "key_code": "down_arrow" }],
"type": "basic"
},
{
"conditions": [
{ "type": "variable_if", "name": "eisu_layer", "value": 1 }
],
"from": { "key_code": "f", "modifiers": { "optional": ["any"] } },
"to": [{ "key_code": "right_arrow" }],
"type": "basic"
},
{
"conditions": [
{ "type": "variable_if", "name": "eisu_layer", "value": 1 }
],
"from": { "key_code": "w", "modifiers": { "optional": ["any"] } },
"to": [{ "key_code": "delete_or_backspace" }],
"type": "basic"
},
{
"conditions": [
{ "type": "variable_if", "name": "eisu_layer", "value": 1 }
],
"from": { "key_code": "r", "modifiers": { "optional": ["any"] } },
"to": [{ "key_code": "return_or_enter" }],
"type": "basic"
},
{
"conditions": [
{ "type": "variable_if", "name": "eisu_layer", "value": 1 }
],
"from": { "key_code": "t", "modifiers": { "optional": ["any"] } },
"to": [{ "key_code": "delete_forward" }],
"type": "basic"
},
{
"conditions": [
{ "type": "variable_if", "name": "eisu_layer", "value": 1 }
],
"from": { "key_code": "x", "modifiers": { "optional": ["any"] } },
"to": [{ "key_code": "home" }],
"type": "basic"
},
{
"conditions": [
{ "type": "variable_if", "name": "eisu_layer", "value": 1 }
],
"from": { "key_code": "v", "modifiers": { "optional": ["any"] } },
"to": [{ "key_code": "end" }],
"type": "basic"
},
{
"conditions": [
{ "type": "variable_if", "name": "eisu_layer", "value": 1 }
],
"from": { "key_code": "a", "modifiers": { "optional": ["any"] } },
"to": [{ "key_code": "tab" }],
"type": "basic"
},
{
"conditions": [
{ "type": "variable_if", "name": "eisu_layer", "value": 1 }
],
"from": { "key_code": "n", "modifiers": { "optional": ["any"] } },
"to": [{ "key_code": "right_command" }],
"type": "basic"
},
{
"conditions": [
{ "type": "variable_if", "name": "eisu_layer", "value": 1 }
],
"from": { "key_code": "h", "modifiers": { "optional": ["any"] } },
"to": [{ "key_code": "right_option" }],
"type": "basic"
},
{
"conditions": [
{ "type": "variable_if", "name": "eisu_layer", "value": 1 }
],
"from": { "key_code": "m", "modifiers": { "optional": ["any"] } },
"to": [{ "key_code": "right_control" }],
"type": "basic"
}
]
}
]
}
まとめ/カスタマイズ例
- JSON中のkey_codeやtoは自由に変更・追加可能
- 例えばshiftやcontrolと組み合わせたサブレイヤーを作成することもできる
ぜひこの設定を導入して、macOSでもホームポジションを保ったまま爆速タイピングを体感してみてください!