2

Has anyone successfully fixed Mac Home/End keys 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?

OSX 10.8+

Shaun
  • 187
  • 1
  • 6

1 Answers1

2

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 https://raw.github.com/tekezo/KeyRemap4MacBook/master/Tests/lib/string/data/checkbox.xml 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>
Lri
  • 40,894
  • 7
  • 119
  • 157
  • cool! I'll try this on Monday at work and see if it works – Shaun Nov 22 '13 at 19:30
  • Yes, this works. Finally I am able to get Home/End to work in Firefox. It was previously not working in the Gmail Compose New Email window and was extremely annoying – Shaun Nov 25 '13 at 09:46
  • Unfortunately, this XML snippet doesn't work in the latest version (14.0), but there is a style already defined there for PC-like copy/paste functionality. – TheAlchemist Oct 17 '14 at 12:56