Modify apple keyboard “home” and “end” button behavior

I recently switched for work to a new Apple Mackbook Pro. Excellent machine even if, coming from KDE, I have something to complain about windows management… but let’s skip to the problem. For my desk setup I use an old Apple Keyboard with Numeric Keypad: I was getting frustrated about the “Home” and “End” button… their actual behavior (e.g. in libreoffice) is to bring you to the beginning/ending of the document instead of beginning/ending of the line you’re on like on Linux (and Windows perhaps).

After a 2 minutes googling I found a solution: you got to create a file (and relative containing directory) with a configuration file tweak for keys bindings. The file is “~/Library/KeyBindings/DefaultKeyBinding.dict” and what you got to in is the following code:

{
   "\UF729"  = moveToBeginningOfLine:; // home
   "\UF72B"  = moveToEndOfLine:; // end
   "$\UF729" = moveToBeginningOfLineAndModifySelection:; // shift-home
   "$\UF72B" = moveToEndOfLineAndModifySelection:; // shift-end
}

This solution it’s not universal… so for example Xcode, Terminal and other cross-platform applications wouldn’t understand them.

References