Update "Home", "End" behavior in Karabiner-Elements

627 views
Skip to first unread message

markie...@gmail.com

unread,
Dec 3, 2017, 2:42:50 PM12/3/17
to Karabiner
I'm sure there is a simple answer to this question, but I haven't been able to locate the modification listed within "Simple" or "Complex Modifications".  I also attempted to edit the .json file, but I am not a coder and can't seem to get it to work.

Simply, I'm looking to change the default Mac "Home" and "End" behavior to mimic a PC "Home" and "End" behavior.

Specifically, I'm looking to change the Mac behavior of moving the cursor to the beginning/end of the document text to instead to move the cursor at the beginning or end of the text line when hitting only the "Home/End" keys.

Any thoughts?

Mark


jvd...@gmail.com

unread,
Jan 3, 2018, 6:02:23 PM1/3/18
to Karabiner
Hi Mark,

I spent a few hours on this matter just now and I have reached a solution.

Here is the code. Just put it in a .json file in /Users/YOURNAME/.config/karabiner/assets/complex_modifications/

{
 
"title": "Fix Home and End keys",
 
"rules": [
   
{
     
"description": "Fix Home and End keys",
     
"manipulators": [
       
{
           
"type": "basic",
           
"from": {
               
"key_code": "right_arrow",
               
"modifiers": {
                   
"mandatory": [
                       
"left_command"
                   
]
               
}
           
},
           
"to": [
               
{
                   
"key_code": "end"
               
}
           
]
       
},
       
{
           
"type": "basic",
           
"from": {
               
"key_code": "end"
           
},
           
"to": [
               
{
                   
"key_code": "right_arrow",
                   
"modifiers": [
                       
"left_command"
                   
]
               
}
           
]
       
},
       
{
           
"type": "basic",
           
"from": {
               
"key_code": "left_arrow",
               
"modifiers": {
                   
"mandatory": [
                       
"left_command"
                   
]
               
}
           
},
           
"to": [
               
{
                   
"key_code": "home"
               
}
           
]
       
},
       
{
           
"type": "basic",
           
"from": {
               
"key_code": "home"
           
},
           
"to": [
               
{
                   
"key_code": "left_arrow",
                   
"modifiers": [
                       
"left_command"
                   
]
               
}
           
]
       
}
     
]
   
}
 
]
}


Let me know if it works for you too.

Cheers!

Joost

jvd...@gmail.com

unread,
Jan 3, 2018, 6:06:23 PM1/3/18
to Karabiner
Even shorter:


{
 
"title": "Fix Home and End keys",
 
"rules": [
   
{
     
"description": "Fix Home and End keys",
     
"manipulators": [
       
{
           
"type": "basic",
           
"from": {

               
"key_code": "end"
           
},
           
"to": [
               
{
                   
"key_code": "right_arrow",
                   
"modifiers": [
                       
"left_command"
                   
]
               
}
           
]
       
},
       
{
           
"type": "basic",
           
"from": {

               
"key_code": "home"
           
},
           
"to": [
               
{
                   
"key_code": "left_arrow",
                   
"modifiers": [
                       
"left_command"
                   
]
               
}
           
]
       
}
     
]
   
}
 
]
}

mike....@gmail.com

unread,
Jun 19, 2019, 3:25:22 PM6/19/19
to Karabiner
First - thank you all very much for this helpful script!

This works great for me when moving the selection around (Home jumps to the start of the line, End jumps to the end).

I've got a problem that I'm having trouble fixing:
When I hold down Shift+Home it reverts to the MacOS behavior (selecting everything between the cursor and the start of the file, not the start of the line).

I wanted to modify what you did in order to allow it to support optional modifiers. I tried the following but Shift+Home still selects everything until the start of the file:



{
  "title": "Fix Home and End keys",
  "rules": [
    {
      "description": "Fix Home and End keys",
      "manipulators": [
        {
            "type": "basic",
            "from": {

                "key_code": "end"
            },
            "to": [
                {
                    "key_code": "right_arrow",
                    "modifiers": [
                        "left_command"
                    ]
                }
            ]
        },
        {
            "type": "basic",
            "from": {

                "key_code": "home",
                "modifiers": { .      **************************** THIS IS THE PART THAT I ADDED :) . *************************************
                    "optional": [
                        "any"
                    ]
                }
            },
            "to": [
                {
                    "key_code": "left_arrow",
                    "modifiers": [
                        "left_command"
                    ]
                }
            ]
        }
      ]
    }
  ]
}
 
According to the docs this looks like it should be right (and the normal 'Home' behavior of jumping to the start of the line still works), I just can't get it to select until the start of the line.

If anyone has any ideas about stuff to look at I'd greatly appreciate any tips, pointers or hints! :)
Reply all
Reply to author
Forward
0 new messages