Mind Dump, Tech And Life Blog
written by Ivan Alenko
published under license Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)copy! share!
posted in category Systems Software / MacOS
posted at 03. Dec '19
last updated at 24. Aug '21

Using an External Keyboard On macOS

Get Home and Keys To Work

mkdir -p ~/Library/Keybindings
nano ~/Library/KeyBindings/DefaultKeyBinding.dict

Put this stuff into the file:

{
/* Remap Home / End keys */
/* Home Button*/
"\UF729" = "moveToBeginningOfLine:";
/* End Button */
"\UF72B" = "moveToEndOfLine:";
/* Shift + Home Button */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:";
/* Shift + End Button */
"$\UF72B" = "moveToEndOfLineAndModifySelection:";
/* Ctrl + Home Button */
"^\UF729" = "moveToBeginningOfDocument:";
/* Ctrl + End Button */
"^\UF72B" = "moveToEndOfDocument:";
 /* Shift + Ctrl + Home Button */
"$^\UF729" = "moveToBeginningOfDocumentAndModifySelection:";
/* Shift + Ctrl + End Button*/
"$^\UF72B" = "moveToEndOfDocumentAndModifySelection:";
}

Restart the computer.

External keyboard vs. ZSH

ZSH is default shell in Catalina, so put this into ~/.zshrc:

bindkey  "^[[H"   beginning-of-line
bindkey  "^[[F"   end-of-line

Now Home and End keys work.

iTerm 2

Go to Preferences - Keys and remove Home and End bindings if it scrolls to the top and bottom.

Add Comment