• You are not logged in.

    Karabiner .json for Extend Layer (For macOS Sierra)

    • Started by zhang0313
    • 2 Replies:
    • Reputation: 0
    • From: Hong Kong
    • Registered: 25-Mar-2019
    • Posts: 2

    I've been using the Extend Mod by DreymaR on my Windows PC and has found it to be quite useful, but was unable to find a Mac version of it that works on OS X Sierra. I had then created a complex modifications file for Karabiner.

    About the Extend Mod:

    The Extend Mod is a modification of the Colemak layout that replaces the Caps Lock key with the Extend key, which allows a variety of functions (including cursor keys, mouse emulation, function keys, and etc.) to be executed without having to move your fingers away from the home row. More details can be found on the original topic. Personally, I found it to reduce finger travel by a significant amount and very useful while editing text and coding.

    Code:

    {
    	"title": "Extend Layer",
    		"rules": [
    			{
    				"description": "Extend Layer",
    				"manipulators": [
    					{
    						"type": "basic",
    						
    						"from": {
    							"key_code": "f19",
    							"modifiers": {
    								"optional": [
    									"any"
    								]
    							}
    						},
    						
                            "to": [
                                {
                                    "set_variable": {
                                        "name": "extend",
                                        "value": 1
                                    }
                                }
                            ],
                            
                            "to_if_alone": [
                                {
                                    "key_code": "delete_or_backspace"
                                }
                            ],
                            
                            "to_after_key_up": [
                                {
                                    "set_variable": {
                                        "name": "extend",
                                        "value": 0
                                    }
                                }
                            ]
    					},
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "q",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "escape"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "1",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "f1"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "2",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "f2"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "3",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "f3"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "4",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "f4"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "5",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "f5"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "6",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "f6"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "7",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "f7"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "8",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "f8"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "9",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "f9"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "0",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "f10"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "hyphen",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "f11"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "equal_sign",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "f12"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "delete_or_backspace",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "tab",
                                    "modifiers": [
                                        "left_command"
                                    ]
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "q",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "left_control"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "w",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "mouse_key": {
                                        "vertical_wheel": -32
                                    }
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "e",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "left_arrow",
                                    "modifiers": [
                                        "left_control"
                                    ]
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "r",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "right_arrow",
                                    "modifiers": [
                                        "left_control"
                                    ]
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "t",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "mouse_key": {
                                        "y": -1536
                                    }
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "y",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "home"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "u",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "page_up"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "i",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "up_arrow"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "o",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "page_down"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "p",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "delete_forward"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "open_bracket",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "escape"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "close_bracket",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "mission_control"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "backslash",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "print_screen"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "a",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "left_option"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "s",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "mouse_key": {
                                        "vertical_wheel": 32
                                    }
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "d",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "left_shift"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "f",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "left_command"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "g",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "mouse_key": {
                                        "y": 1536
                                    }
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "h",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "end"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "j",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "left_arrow"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "k",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "down_arrow"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "l",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "right_arrow"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "semicolon",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "delete_or_backspace"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "z",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "z",
                                    "modifiers": [
                                        "left_command"
                                    ]
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "x",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "x",
                                    "modifiers": [
                                        "left_command"
                                    ]
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "c",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "c",
                                    "modifiers": [
                                        "left_command"
                                    ]
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "v",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "v",
                                    "modifiers": [
                                        "left_command"
                                    ]
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "b",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "b",
                                    "modifiers": [
                                        "left_command"
                                    ]
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "comma",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "mouse_key": {
                                        "x": -1536
                                    }
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "period",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "mouse_key": {
                                        "x": 1536
                                    }
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        },
                        {
                            "type": "basic",
                            
                            "from": {
                                "key_code": "space",
                                "modifiers": {
                                    "optional": [
                                        "any"
                                    ]
                                }
                            },
                            
                            "to": [
                                {
                                    "key_code": "enter"
                                }
                            ],
                            "conditions": [
                                {
                                    "type": "variable_if",
                                    "name": "extend",
                                    "value": 1
                                }
                            ]
                        }
                    ]
                }
            ]
        }

    To install:
    1. Install Karabiner. It is not necessary for Seil to be installed.
    2. Copy the code into TextEdit, then save it as a .json file.
    3. Put the file into ~/.config/karabiner/assets/complex_modifications
    4. Open Karabiner, go to the Complex-Modifications tab, open the menu, and select 'Extend Layers'.

    Note:
    1. You must map the desired key to F19 in order to make it function as Extend.
    2. If Extend is pressed alone, it functions as backspace.

    Update 2019-05-21:
    • Extend now functions as backspace if pressed alone.
    • Fixed the broken Command + ZXCV shortcuts.
    • Extend is now mapped to F19 instead of Caps Lock by default.

    To do:
    • Add the Extend2 layer and map it to F20.

    Last edited by zhang0313 (21-May-2019 02:50:52)
    Offline
    • 0
    • Reputation: 210
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,343

    That looks like a lot of work, so grats! ^_^

    How does it compare to the ones by Aldo39 or BenDover178 or MattMc3 or others mentioned in the Mac Extend topic?

    Looks to me like the biggest problem with these implementations is that they don't allow for ergo mods on top, so you're stuck with or without CurlAngleWide.

    Last edited by DreymaR (20-May-2019 11:02:09)

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0
    • Reputation: 0
    • From: Hong Kong
    • Registered: 25-Mar-2019
    • Posts: 2

    I tested my script while using Colemak-CAW and found it to be working quite well. Due to Karabiner works by only changing the key codes, it, theoretically, is compatible with all layouts, even Dvorak. However, due to Z being at the B position in QWERTY, Command+Z will interfere with the left mouse button (Extend+B), causing problems. I have excluded mouse buttons in my code and changed Extend+B to be Command+B (Command+Z using CAW) because of this.

    Another modification I had made from the original Extend and MattMc3's version is that Extend+E and Extend+R (in QWERTY positions) now moves between desktops and full-screen applications, which I think might be more useful. Tapping Extend is also now backspace since I am having trouble moving backspace from caps lock to Extend+;.

    Offline
    • 0