Skip to content

Instantly share code, notes, and snippets.

@mshannaq
Last active December 18, 2023 14:24
Show Gist options
  • Save mshannaq/fc63b98337a01ea4a05fb871229c4f4d to your computer and use it in GitHub Desktop.
Save mshannaq/fc63b98337a01ea4a05fb871229c4f4d to your computer and use it in GitHub Desktop.
define 'Home' and 'End' on MacOS (uses Microsoft Keyboard) to be like Microsoft Windows
As you know in Microsoft Windows there is a button 'Home' which go to the begning of line and and button 'End' goes to the end of line.
In MacOS if you use Keyboard others that Mac Keyboard you cannot use 'Home' and 'End' button because it is not defined.
buu sure you can customize it and use it exactly as you use on Microsoft Keyboard
to do that open terminal and goto folder `~/Library/KeyBindings/` by running the command
```bash
cd ~/Library/KeyBindings/
```
if the folder `KeyBindings` does not exists you can make it by running the command
```
cd cd ~/Library
mkdir KeyBindings
```
then goto the folder `KeyBindings` and create a new file names `DefaultKeyBinding.dict` using
```
cd ~/Library/KeyBindings/
nano DefaultKeyBinding.dict
```
and Add the following code to the file and save it
```
{
"\UF729" = moveToBeginningOfLine:; // home
"\UF72B" = moveToEndOfLine:; // end
"$\UF729" = moveToBeginningOfLineAndModifySelection:; // shift-home
"$\UF72B" = moveToEndOfLineAndModifySelection:; // shift-end
}
```
this will define the `home` button. to goto begning of line and define the end button to go to the end of line.
Applying changes requires reopening applications.
DefaultKeyBinding.dict is ignored by some old versions of Xcode (works with latest version 6.3.1), Terminal, and many cross-platform applications.
this was tested on MacOS 14.2 (Sonoma)
also you can take a look into this https://gist.github.com/trusktr/1e5e516df4e8032cbc3d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment