Karabiner-Elements

そろそろ定期的にクリーンインストールをしたい病がでてきたので、OSをインストールしなおすことに。
使っているソフトの関係で、まだsierraなんですけどね。

今までkeyhacにずっとお世話になっていたのですが、Karabiner-Elementsが大分バージョンアップしていたので、戻すことにしました。

インストール

brew caskを使って

brew cask install Karabiner-Elements

以上で終了。

設定

いくつかの設定ファイルも公開されていますが……

  1. SandSで入力を行う。
  2. 「かな」「英数」をCTRLのようなモディファイヤキーとして使用する。

の2点を実現したいので、自分でjsonファイルを作成します。
作ったのはこちら。

"title": "SandS"
"rules": [
{
	"manipulators": [
	{
		"description": "Change spacebar to left_shift. (Post spacebar if pressed alone)",
			"from": {
				"key_code": "spacebar",
				"modifiers": {
					"optional": [
						"any"
					]
				}
			},
			"to": [
			{
				"key_code": "left_shift"
			}
			],
			"to_if_alone": [
			{
				"key_code": "spacebar"
			}
			],
			"type": "basic"
	}
	]
}
]

でもって、「英数」キーを押しながらhjklで上下左右にカーソルを動かすvimライクな設定はこちら

{
	"title": "Eisu to Modifier",
	"rules": [
		{
			"description": "Change EISU to Modifier",
			"manipulators": [
				{
					"type": "basic",
					"from": { 
						"key_code": "h",
						"modifiers":{
							"optional": [
								"any"
							]
						}
					},
					"to": [
						{ 
							"key_code": "left_arrow"
						}
					],
					"conditions": [
						{ 
							"type": "variable_if", 
							"name": "eisuu", 
							"value": 1
						}
					]
				},
				{
					"type": "basic",
					"from": { 
						"key_code": "j",
						"modifiers":{
							"optional": [
								"any"
							]
						}
					},
					"to": [
						{ 
							"key_code": "down_arrow"
						}
					],
					"conditions": [
						{ 
							"type": "variable_if", 
							"name": "eisuu", 
							"value": 1
						}
					]
				},
				{
					"type": "basic",
					"from": { 
						"key_code": "k",
						"modifiers":{
							"optional": [
								"any"
							]
						}
					},
					"to": [
						{ 
							"key_code": "up_arrow"
						}
					],
					"conditions": [
						{ 
							"type": "variable_if", 
							"name": "eisuu", 
							"value": 1
						}
					]
				},
				{
					"type": "basic",
					"from": { 
						"key_code": "l",
						"modifiers":{
							"optional": [
								"any"
							]
						}
					},
					"to": [
						{ 
							"key_code": "light_arrow"
						}
					],
					"conditions": [
						{ 
							"type": "variable_if", 
							"name": "eisuu", 
							"value": 1
						}
					]
				},
				{
					"type": "basic",
					"from": {
						"key_code": "japanese_eisuu"
					},
					"to": [
						{
							"set_variable": {
								"name": "eisuu",
								"value": 1
							}
						}
					],
					"to_after_key_up": [
						{
							"set_variable": {
								"name": "eisuu",
								"value": 0
							}
						}
					]
				}
			]
		}
	]
}

これを
/Users/[ユーザー名]/.config/karabiner/assets/complex_modifications
に保存しておけば、設定ファイルのComplex_modificationsに表示されるから、適用すればOK
大元のkarabiner.jsonを直接編集しなくていいから注意。
それとjsonファイルは文法間違いがあると表示されないから注意。
最初の行のtitleの最後に「,」を忘れただけで、表示されないから間違いを見付けるのが大変だった。