以前karaninerにfnキーを割り当てたいが 無理だったのでHammerspoonにいきついた話という記事を書きました。
hammerspoonに行き着いたのは紛れもない事実で
素晴らしかったのですが
あのやり方では、どうあがいても私の
分離キーボードという環境が大きいのかもしれませんが、
どうあがいてもfn + jkli での矢印キーが実現できませんでした。ですので現実解としてctrl + jkliとしていたのですが
結構使用頻度高い iTerm2との干渉で ctrl + Lでclearができなかったらctrl + uで一行削除だったらたりが効かなくなってしまっていました。また、chromeのExtensionが一部ショートカットがうまく動かず、意図せず絵文字viewerならぬものがやたら立ち上がったりするようになりましたw
そんなストレスとはおさらばしたく
再度
karabinerでなんとかならないものか。
挑戦することんしました。
なぜ、またkarabinerかというと
karabiner multiple keyboardsとググって
一応ディフォルトではkarabinerは別々のdeviceから入力されたmodiferでも機能するとstackoverflowやらで書かれていたかからです。
以前karabinerを諦めてhammerspoonに写った理由はfnが分離キーボードをまたがって認識されていなかったからです。fnだけではなく、cmdやaltも同じでした。なぜかshiftは機能してました。
しかし、そのようなぐぐり結果からも
もしや、やっぱりkarabinerしかこれを実現できないじゃないか。これまでやってきた、simple_modificationではなくcomplex_modificationならなんとかなるかもしれない、とにかくやってみよう、という思いでした。
すると
なんとcomplex_modificationを挑戦してみたところ
見事
思い通りに
動作しました!
分離キーボードをまたいでfnキーが認識されて
指定の動作をしてくれるようになりました!
その
設定configの内容は以下のとおりです。
本当に嬉しいです。
もし、新しいキーボードを買い足しても
この設定を覚えてさえおけば、ハードウェア的にキーボードのマッピングをしなくても全部ソフト的にkarabinerで達成できてしまえるのも狙いでした。
complex_modificationのところだけ抜粋です。simple_modificationはdeviceごとの反映ができますが、complex_modificationはProfileに掛かり、deviceごとの反映はできないっぽいです。
{
"complex_modifications": {
"parameters": {
"basic.simultaneous_threshold_milliseconds": 50,
"basic.to_delayed_action_delay_milliseconds": 500,
"basic.to_if_alone_timeout_milliseconds": 1000,
"basic.to_if_held_down_threshold_milliseconds": 500,
"mouse_motion_to_scroll.speed": 100
},
"rules": [
{
"manipulators": [
{
"from": {
"key_code": "j",
"modifiers": {
"mandatory": [
"fn"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "left_arrow"
}
],
"type": "basic"
},
{
"from": {
"key_code": "l",
"modifiers": {
"mandatory": [
"fn"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "right_arrow"
}
],
"type": "basic"
},
{
"from": {
"key_code": "i",
"modifiers": {
"mandatory": [
"fn"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "up_arrow"
}
],
"type": "basic"
},
{
"from": {
"key_code": "k",
"modifiers": {
"mandatory": [
"fn"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "down_arrow"
}
],
"type": "basic"
},
{
"from": {
"key_code": "spacebar",
"modifiers": {
"mandatory": [
"fn"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "return_or_enter"
}
],
"type": "basic"
},
{
"from": {
"key_code": "u",
"modifiers": {
"mandatory": [
"fn"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "delete_or_backspace"
}
],
"type": "basic"
},
{
"from": {
"key_code": "o",
"modifiers": {
"mandatory": [
"fn"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "delete_or_backspace"
}
],
"type": "basic"
},
{
"from": {
"key_code": "v",
"modifiers": {
"mandatory": [
"fn"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "v",
"modifiers": [
"command"
]
}
],
"type": "basic"
},
{
"from": {
"key_code": "c",
"modifiers": {
"mandatory": [
"fn"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "c",
"modifiers": [
"command"
]
}
],
"type": "basic"
},
{
"from": {
"key_code": "z",
"modifiers": {
"mandatory": [
"fn"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "z",
"modifiers": [
"command"
]
}
],
"type": "basic"
},
{
"from": {
"key_code": "x",
"modifiers": {
"mandatory": [
"fn"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "x",
"modifiers": [
"command"
]
}
],
"type": "basic"
},
{
"from": {
"key_code": "f",
"modifiers": {
"mandatory": [
"fn"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "d",
"modifiers": [
"command"
]
}
],
"type": "basic"
}
]
}
]
}
karabinerの設定にやくだったらサイトはこちら
karabiner/json.html#typical-complex_modifications-examples
【人権回復】Karabiner-ElementsでOne-to-many, Many-to-oneマッピング
以上です