4

I am on OSX 10.8+ and has anyone successfully fixed Mac Home/End keys functionality permanently? And I mean Home/End actually go to the beginning and end of the line.

KeyRemap4MacBook works almost everywhere but there are still certain situations where it does not work.

I'm thinking this could be solved with setxkbmap. I'll be reading the documentation in the next few days… but has anyone else figured this out?

Giacomo1968
  • 58,727
Shaun
  • 217

2 Answers2

3

Another way to remap home and end is to save a property list like this as ~/Library/KeyBindings/DefaultKeyBinding.dict:

{
  "\UF729" = moveToBeginningOfLine:;
  "\UF72B" = moveToEndOfLine:;
  "$\UF729" = moveToBeginningOfLineAndModifySelection:;
  "$\UF72B" = moveToEndOfLineAndModifySelection:;
}

It doesn't work in as many places as KeyRemap4MacBook, but there are also less false positives.

If you use one of the predefined settings in KeyRemap4MacBook, you can customize it by copying it from this XML file to private.xml:

<?xml version="1.0"?>
<root>
  <item>
    <name>Use PC Style Home/End (except in Virtual Machine,RDC)</name>
    <appendix>(Change Home to Command+Left)</appendix>
    <appendix>(Change End to Command+Right)</appendix>
    <appendix>(+ Change Home to Control+A in Emacs,Terminal,X11,Eclipse)</appendix>
    <appendix>(+ Change End to Control+E in Emacs,Terminal,X11,Eclipse)</appendix>
    <identifier>remap.pclikehomeend</identifier>
    <block>
      <only>DREAMWEAVER</only>
      <autogen>__KeyToKey__ FROMKEYCODE_HOME, KeyCode::HOME, ModifierFlag::SHIFT_L</autogen>
      <autogen>__KeyToKey__ FROMKEYCODE_END,  KeyCode::END,  ModifierFlag::SHIFT_L</autogen>
    </block>
    <block>
      <only>BLUEFISH,WORD,EXCEL,POWERPOINT</only>
      <autogen>__KeyToKey__ FROMKEYCODE_HOME, KeyCode::HOME</autogen>
      <autogen>__KeyToKey__ FROMKEYCODE_END,  KeyCode::END</autogen>
    </block>
    <block>
      <not>EMACS, TERMINAL, VIRTUALMACHINE, REMOTEDESKTOPCONNECTION, X11, ECLIPSE</not>
      <autogen>__KeyToKey__ FROMKEYCODE_HOME, VK_COMMAND, KeyCode::CURSOR_UP,    ModifierFlag::COMMAND_L</autogen>
      <autogen>__KeyToKey__ FROMKEYCODE_HOME, VK_CONTROL, KeyCode::CURSOR_UP,    ModifierFlag::COMMAND_L</autogen>
      <autogen>__KeyToKey__ FROMKEYCODE_END,  VK_COMMAND, KeyCode::CURSOR_DOWN,  ModifierFlag::COMMAND_L</autogen>
      <autogen>__KeyToKey__ FROMKEYCODE_END,  VK_CONTROL, KeyCode::CURSOR_DOWN,  ModifierFlag::COMMAND_L</autogen>
      <autogen>__KeyToKey__ FROMKEYCODE_HOME,             KeyCode::CURSOR_LEFT,  ModifierFlag::COMMAND_L</autogen>
      <autogen>__KeyToKey__ FROMKEYCODE_END,              KeyCode::CURSOR_RIGHT, ModifierFlag::COMMAND_L</autogen>
    </block>
    <block>
      <only>EMACS, TERMINAL, X11, ECLIPSE</only>
      <autogen>__KeyToKey__ FROMKEYCODE_HOME, KeyCode::A, ModifierFlag::CONTROL_L</autogen>
      <autogen>__KeyToKey__ FROMKEYCODE_END,  KeyCode::E, ModifierFlag::CONTROL_L</autogen>
    </block>
  </item>
</root>

You can use an appdef element to specify a new application:

<appdef>
  <appname>TEXTMATE</appname>
  <equal>com.macromates.TextMate.preview</equal>
  <equal>com.macromates.TextMate</equal>
</appdef>
Giacomo1968
  • 58,727
Lri
  • 42,502
  • 8
  • 126
  • 159
0

Try out Karabiner-Elements: https://karabiner-elements.pqrs.org/

This was the only way I could successfully map home and end keys in MacOS Sanoma (14.3.1)

Andrew
  • 647