LoginSignup
1
2

More than 3 years have passed since last update.

enthumbleっぽい使い勝手をMacに再現する 2019年版

Posted at

新しいMacで設定しているHammerspoonとKarabinerElementsの設定を残しておきます。

古い設定はこれ https://qiita.com/shwld/items/f7ffbc1dbcc76d855c6a

Emthumbleが好きなので英数押しながら他のキーを使って便利ショートカットを使えるように設定しています。

~/.hammerspoon/init.lua
local function keyCode(key, modifiers)
   modifiers = modifiers or {}
   return function()
      hs.eventtap.event.newKeyEvent(modifiers, string.lower(key), true):post()
      hs.timer.usleep(1000)
      hs.eventtap.event.newKeyEvent(modifiers, string.lower(key), false):post()
   end
end

local function launchOrFocus(name)
    return function()
        hs.application.launchOrFocus(name)
    end
end

local function remapKey(modifiers, key, keyCode)
   hs.hotkey.bind(modifiers, key, keyCode, nil, keyCode)
end

-- カーソル移動
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 'h', keyCode('left'))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 'j', keyCode('down'))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 'k', keyCode('up'))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 'l', keyCode('right'))
remapKey({'rightalt', 'rightctrl', 'rightcmd', 'shift'}, 'h', keyCode('left', {'shift'}))
remapKey({'rightalt', 'rightctrl', 'rightcmd', 'shift'}, 'j', keyCode('down', {'shift'}))
remapKey({'rightalt', 'rightctrl', 'rightcmd', 'shift'}, 'k', keyCode('up', {'shift'}))
remapKey({'rightalt', 'rightctrl', 'rightcmd', 'shift'}, 'l', keyCode('right', {'shift'}))

-- 画面調整
remapKey({'leftalt', 'leftcmd'}, 'h', keyCode('left', {'cmd', 'alt'}))
remapKey({'leftalt', 'leftcmd'}, 'j', keyCode('down', {'cmd', 'alt'}))
remapKey({'leftalt', 'leftcmd'}, 'k', keyCode('up', {'cmd', 'alt'}))
remapKey({'leftalt', 'leftcmd'}, 'l', keyCode('right', {'cmd', 'alt'}))

-- タブ
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, ',', keyCode(']', {'cmd', 'shift'}))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, '.', keyCode('\\', {'cmd', 'shift'}))

-- タブ
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, ';', keyCode('pageup'))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, '/', keyCode('pagedown'))

-- ESC
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 'space', keyCode('escape'))

-- `~
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, '1', keyCode('`'))
remapKey({'rightalt', 'rightctrl', 'rightcmd', 'shift'}, '1', keyCode('`', {'shift'}))

-- right rightcmd
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 'return', keyCode('space', {'ctrl'}))

-- semicolon, slash
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 'i', keyCode('left', {'cmd'}))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 'o', keyCode('right', {'cmd'}))
remapKey({'rightalt', 'rightctrl', 'rightcmd', 'shift'}, 'i', keyCode('left', {'cmd', 'shift'}))
remapKey({'rightalt', 'rightctrl', 'rightcmd', 'shift'}, 'o', keyCode('right', {'cmd', 'shift'}))

-- TODO: asdf
-- remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 's', keyCode('s', {'cmd'}))

-- p
-- remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 'p', keyCode('p', {'cmd'}))

-- x
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 'x', keyCode('w', {'cmd'}))

-- qwertyu
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 'q', launchOrFocus('Finder'))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 'w', keyCode('1', {'cmd'}))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 'e', keyCode('2', {'cmd'}))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 'r', keyCode('3', {'cmd'}))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 't', keyCode('4', {'cmd'}))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 'y', keyCode('5', {'cmd'}))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, 'u', keyCode('6', {'cmd'}))

-- 1234567890
-- remapKey({'rightalt', 'rightctrl', 'rightcmd'}, '1', keyCode('f1'))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, '2', keyCode('f2'))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, '3', keyCode('f3'))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, '4', keyCode('f4'))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, '5', keyCode('f5'))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, '6', keyCode('f6'))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, '7', keyCode('f7'))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, '8', keyCode('f8'))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, '9', keyCode('f9'))
remapKey({'rightalt', 'rightctrl', 'rightcmd'}, '0', keyCode('f10'))
~/.config/karabiner/karabiner.json
{
    "global": {
        "check_for_updates_on_startup": true,
        "show_in_menu_bar": true,
        "show_profile_name_in_menu_bar": true
    },
    "profiles": [
        {
            "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": [
                    {
                        "description": "英数・かなキーを他のキーと組み合わせて押したときに、独自キーを送信する。",
                        "manipulators": [
                            {
                                "from": {
                                    "key_code": "japanese_eisuu",
                                    "modifiers": {
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "right_command",
                                        "modifiers": [
                                            "right_control",
                                            "right_option"
                                        ]
                                    }
                                ],
                                "to_if_alone": [
                                    {
                                        "key_code": "japanese_eisuu"
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "from": {
                                    "key_code": "japanese_kana",
                                    "modifiers": {
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "right_command",
                                        "modifiers": [
                                            "right_control",
                                            "right_option"
                                        ]
                                    }
                                ],
                                "to_if_alone": [
                                    {
                                        "key_code": "japanese_kana"
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    }
                ]
            },
            "devices": [
                {
                    "disable_built_in_keyboard_if_exists": false,
                    "fn_function_keys": [],
                    "identifiers": {
                        "is_keyboard": true,
                        "is_pointing_device": false,
                        "product_id": 603,
                        "vendor_id": 1452
                    },
                    "ignore": false,
                    "manipulate_caps_lock_led": true,
                    "simple_modifications": []
                },
                {
                    "disable_built_in_keyboard_if_exists": false,
                    "fn_function_keys": [],
                    "identifiers": {
                        "is_keyboard": true,
                        "is_pointing_device": false,
                        "product_id": 1649,
                        "vendor_id": 3897
                    },
                    "ignore": false,
                    "manipulate_caps_lock_led": false,
                    "simple_modifications": []
                },
                {
                    "disable_built_in_keyboard_if_exists": false,
                    "fn_function_keys": [],
                    "identifiers": {
                        "is_keyboard": true,
                        "is_pointing_device": false,
                        "product_id": 65535,
                        "vendor_id": 1452
                    },
                    "ignore": true,
                    "manipulate_caps_lock_led": true,
                    "simple_modifications": []
                },
                {
                    "disable_built_in_keyboard_if_exists": true,
                    "fn_function_keys": [],
                    "identifiers": {
                        "is_keyboard": true,
                        "is_pointing_device": false,
                        "product_id": 323,
                        "vendor_id": 1241
                    },
                    "ignore": false,
                    "manipulate_caps_lock_led": false,
                    "simple_modifications": [
                        {
                            "from": {
                                "key_code": "caps_lock"
                            },
                            "to": {
                                "key_code": "left_control"
                            }
                        },
                        {
                            "from": {
                                "key_code": "grave_accent_and_tilde"
                            },
                            "to": {
                                "key_code": "escape"
                            }
                        },
                        {
                            "from": {
                                "key_code": "left_command"
                            },
                            "to": {
                                "key_code": "left_option"
                            }
                        },
                        {
                            "from": {
                                "key_code": "left_option"
                            },
                            "to": {
                                "key_code": "left_command"
                            }
                        }
                    ]
                },
                {
                    "disable_built_in_keyboard_if_exists": false,
                    "fn_function_keys": [],
                    "identifiers": {
                        "is_keyboard": true,
                        "is_pointing_device": false,
                        "product_id": 34304,
                        "vendor_id": 1452
                    },
                    "ignore": false,
                    "manipulate_caps_lock_led": true,
                    "simple_modifications": []
                }
            ],
            "fn_function_keys": [
                {
                    "from": {
                        "key_code": "f1"
                    },
                    "to": {
                        "key_code": "f1"
                    }
                },
                {
                    "from": {
                        "key_code": "f2"
                    },
                    "to": {
                        "key_code": "f2"
                    }
                },
                {
                    "from": {
                        "key_code": "f3"
                    },
                    "to": {
                        "key_code": "f3"
                    }
                },
                {
                    "from": {
                        "key_code": "f4"
                    },
                    "to": {
                        "key_code": "f4"
                    }
                },
                {
                    "from": {
                        "key_code": "f5"
                    },
                    "to": {
                        "key_code": "f5"
                    }
                },
                {
                    "from": {
                        "key_code": "f6"
                    },
                    "to": {
                        "key_code": "f6"
                    }
                },
                {
                    "from": {
                        "key_code": "f7"
                    },
                    "to": {
                        "key_code": "f7"
                    }
                },
                {
                    "from": {
                        "key_code": "f8"
                    },
                    "to": {
                        "key_code": "f8"
                    }
                },
                {
                    "from": {
                        "key_code": "f9"
                    },
                    "to": {
                        "key_code": "f9"
                    }
                },
                {
                    "from": {
                        "key_code": "f10"
                    },
                    "to": {
                        "key_code": "f10"
                    }
                },
                {
                    "from": {
                        "key_code": "f11"
                    },
                    "to": {
                        "key_code": "f11"
                    }
                },
                {
                    "from": {
                        "key_code": "f12"
                    },
                    "to": {
                        "key_code": "f12"
                    }
                }
            ],
            "name": "JIS",
            "one_to_many_mappings": {
                "japanese_eisuu": [
                    "right_option",
                    "right_control",
                    "right_command"
                ],
                "japanese_kana": [
                    "right_option",
                    "right_control",
                    "right_command"
                ]
            },
            "parameters": {
                "delay_milliseconds_before_open_device": 1000
            },
            "selected": true,
            "simple_modifications": [
                {
                    "from": {
                        "key_code": "japanese_pc_katakana"
                    },
                    "to": {
                        "key_code": "return_or_enter"
                    }
                },
                {
                    "from": {
                        "key_code": "japanese_pc_nfer"
                    },
                    "to": {
                        "key_code": "japanese_eisuu"
                    }
                },
                {
                    "from": {
                        "key_code": "japanese_pc_xfer"
                    },
                    "to": {
                        "key_code": "japanese_kana"
                    }
                },
                {
                    "from": {
                        "key_code": "right_command"
                    },
                    "to": {
                        "key_code": "return_or_enter"
                    }
                }
            ],
            "standalone_keys": {
                "japanese_eisuu": "japanese_eisuu",
                "japanese_kana": "japanese_kana"
            },
            "standalone_keys_delay_milliseconds": 200,
            "virtual_hid_keyboard": {
                "caps_lock_delay_milliseconds": 0,
                "country_code": 0,
                "keyboard_type": "jis",
                "mouse_key_xy_scale": 100,
                "standalone_keys_delay_milliseconds": 200
            }
        },
        {
            "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": []
            },
            "devices": [],
            "fn_function_keys": [
                {
                    "from": {
                        "key_code": "f1"
                    },
                    "to": {
                        "key_code": "display_brightness_decrement"
                    }
                },
                {
                    "from": {
                        "key_code": "f2"
                    },
                    "to": {
                        "key_code": "display_brightness_increment"
                    }
                },
                {
                    "from": {
                        "key_code": "f3"
                    },
                    "to": {
                        "key_code": "mission_control"
                    }
                },
                {
                    "from": {
                        "key_code": "f4"
                    },
                    "to": {
                        "key_code": "launchpad"
                    }
                },
                {
                    "from": {
                        "key_code": "f5"
                    },
                    "to": {
                        "key_code": "illumination_decrement"
                    }
                },
                {
                    "from": {
                        "key_code": "f6"
                    },
                    "to": {
                        "key_code": "illumination_increment"
                    }
                },
                {
                    "from": {
                        "key_code": "f7"
                    },
                    "to": {
                        "key_code": "rewind"
                    }
                },
                {
                    "from": {
                        "key_code": "f8"
                    },
                    "to": {
                        "key_code": "play_or_pause"
                    }
                },
                {
                    "from": {
                        "key_code": "f9"
                    },
                    "to": {
                        "key_code": "fastforward"
                    }
                },
                {
                    "from": {
                        "key_code": "f10"
                    },
                    "to": {
                        "key_code": "mute"
                    }
                },
                {
                    "from": {
                        "key_code": "f11"
                    },
                    "to": {
                        "key_code": "volume_decrement"
                    }
                },
                {
                    "from": {
                        "key_code": "f12"
                    },
                    "to": {
                        "key_code": "volume_increment"
                    }
                }
            ],
            "name": "US",
            "one_to_many_mappings": {
                "japanese_eisuu": [
                    "right_option",
                    "right_control",
                    "right_command"
                ],
                "japanese_kana": [
                    "right_option",
                    "right_control",
                    "right_command"
                ]
            },
            "parameters": {
                "delay_milliseconds_before_open_device": 1000
            },
            "selected": false,
            "simple_modifications": [
                {
                    "from": {
                        "key_code": "escape"
                    },
                    "to": {
                        "key_code": "grave_accent_and_tilde"
                    }
                },
                {
                    "from": {
                        "key_code": "right_command"
                    },
                    "to": {
                        "key_code": "escape"
                    }
                }
            ],
            "standalone_keys": {
                "japanese_eisuu": "japanese_eisuu",
                "japanese_kana": "japanese_kana"
            },
            "virtual_hid_keyboard": {
                "caps_lock_delay_milliseconds": 0,
                "country_code": 0,
                "keyboard_type": "ansi",
                "mouse_key_xy_scale": 100,
                "standalone_keys_delay_milliseconds": 200
            }
        }
    ]
}
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2