Make Home & End keys behave like Windows on Mac OS X
- 📅
- 📝 243 words
- 🕙 2 minutes
- 📦 Apple
- 🏷️ keyboards, macOS
- 💬 80 responses
I’ve been using Mac OS X daily since 2001 when I purchased my Titanium PowerBook. I still can’t get used the Home and End key behaviour.
If, like me, you want Home to send you to the start of the line and not to the top of the document, then create a file called DefaultKeyBinding.dict
in your ~/Library/KeyBindings
folder (might need to create that folder too) with the following contents:
{
"\UF729" = moveToBeginningOfParagraph:; // home
"\UF72B" = moveToEndOfParagraph:; // end
"$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // shift-home
"$\UF72B" = moveToEndOfParagraphAndModifySelection:; // shift-end
"^\UF729" = moveToBeginningOfDocument:; // ctrl-home
"^\UF72B" = moveToEndOfDocument:; // ctrl-end
"^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; // ctrl-shift-home
"^$\UF72B" = moveToEndOfDocumentAndModifySelection:; // ctrl-shift-end
}
This remapping does the following in most Mac apps — including Chrome (some apps manage their key handling directly):
- Home and End will go to start and end of line
- ShiftHome and ShiftEnd will select to start and end of line
- CtrlHome and CtrlEnd will go to start and end of document
- ShiftCtrlHome and ShiftCtrlEnd will select to start and end of document
Note that you need to reboot after creating this file for it to take effect. Also make sure your editor does not append TXT
to the end of it!
If you have a PC keyboard with LED back-lighting and would like the scroll-lock, num-lock or caps-lock LEDs on when using your Mac check out my free SetLEDs for Mac
[)amien
80 responses to Make Home & End keys behave like Windows on Mac OS X
For me the following config does not work on Sequoia for Home/End key => beginning/end of line:
Anyone else having this issue on Sequoia. IIRC it worked fine on macos version before this one.
Anyone get this to work with Microsoft’s OneNote on MacBook Pro? Is there a separate solution for that app.?
MBP 16″ of 2023 on Sonoma 14.3. Can’t get it to work. Basically tried all variations: With/Without Reboot, killall Finder, etc. “Line” instead of “Paragraph” — the behavior is always the same. Home/End key do not jump to beginning/end of line. Some examples show a double “” some use a single “". Some write the file with a capital Dict, some lowercase.
My latest attempt:
Tried 010 Editor and BBEdit — both show the normal behavior to just jump to the begin/end of the document and not the start/end of the current line.
Anyone here who can definitely say it works for him on Sonoma? (And how his file looks like)
Thanks!
Glad to know I’m not the only one who gets really tripped up by the home/end behavior on Mac … : ) Yes, this is very valuable.
For all those who don’t know, in case it’s helpful, Cmd+Left Arrow and Cmd+Right Arrow natively do the same function on Mac, in almost all contexts … so if you are without a full keyboard, that can help.
I once had a job working (as a programmer) in an environment of all Macs, after not using Mac much at all for many years, and that was the one huge thing I remember being frustrated by … my coworkers seemed to think I was nuts. But now I know it’s not just me!!
I prefer using Mac these days, but when I am, I still prefer having Home/End go to beginning/end of line … it’s still easier than Cmd+Left/Right, and muscle memory still has it ingrained. (In order to hit Cmd+Left/Right, you still have to move your right hand over to the arrow keys anyway, which are right under Home and End, at least on most keyboards)
Thanks again. I used Karabiner and another program for a long time to do this, but it’s nicer to know how to do it without installing any other dependencies, and especially for on computers where I may not be allowed to install helper programs to do such things.
Worked like a charm. MBP 13-inch, 2017, Ventura
Thanks a lot, guys. On Mac Ventura latest OS It works as advertised. By the way, does anybody know how to use or program F13 through F19 on the Magic Keyboard?
Here’s my DefaultKeyBinding.dict that I put together with the various comments above. Includes both beginning/end of line and beginning/end of paragraph as well as beginning/end of document and beginning/end of word plus the change selection versions. Works well for me on Catalina. killall Finder does work though you also need to quit any application you want to be affected by it.
Can anyone get this working on Ventura 13.2?
Working successfully on macOS Ventura 13.1. Many thanks!
Works like charm on On MacOS Ventura 13.0.1 (22A400), Apple M1 Pro ! Thank you D
TOP! Worked like a charm! Thanks
Did not work for me on Ventura
This is just a thank you to [)amien and all followup commenters — this is still useful and working information in Nov 2022 on MacOS Ventura :-)
Life saver indeed! Works on Ventura also!
Keeps working like a charm in Monterey 12.4. thanks a lot, Damien!
Just brilliant — accidentally hitting to End key and jumping to the end of the doc when using a MS style keyboard plugged into my mac was pretty annoying.. This worked a dream.
Man you are such a life saver. It’s so irritating how MacOS has HOME and END keys mapped. Ridiculous. Apple is always ‘my way or highway, u be damned’ attitude. But thankfully we have samaritans like you who save the day and make us live another day!! Thankyou again.. May you get everything you wish in life! :)
Big Sur 11.6 on a M1 Macbook Pro and the code in the article is still working 👌
Since vcode does not support this file, here’s what I’ve put to my
keybindings.json
in vscode to make the muscle memory work in vscode too (note: I bound all shortcuts to both ctrl-… and cmd-… just to make my life easier; and I had to unbind some MacOS-specific vscode default keybindings).Thanks for this writeup.
Unfortunately vscode does not support this settings file, and the relevant issue was closed (not enough upvotes)
https://github.com/microsoft/vscode/issues/111950
But it’s possible to customize key bindings directly in vscode:
cmd-shift-p
> Keyboard shortcuts > typecursor
in the search fieldThis worked. You are a life saver. I was getting so frustrated using my PC keyboard on my Macbook.
In the middle of learning a new programming language, it’s no good that I can’t get to the end of a line or the beginning of a line easily! Gets in the way of learning.
Thank you so much for sharing this and help the community! Kudos and Respect!
I too would like to declare my undying love for saving me lots of swearing and lost time when developing on MacOS.
Working fine on BigSur 11.6
Less techy peeps: don’t be put off by earlier comments that terminal access is required — it’s not required.
First use any editor (TextEdit if that’s all you have) to create the file and save it to an easily accessible folder, such as Documents.
Then to access Library folder just hold down option (alt) while clicking Go menu in Finder — Library will be in the list, you can then use Finder to create the KeyBindings folder in there as normal and drag in the DefaultKeyBinding file you made earlier.
To apply the settings without rebooting just click the apple in top left, choose Force quit… select Finder and choose Relaunch. You’ll also need to quit/restart any open applications.
Additional useful bindings that are missing from this post to make it more productive and Windows:
Though as Other Rich says above you’ll need to disable the Mission Control ctrl left/right bindings in System preferences for those to work.
I too have benefitted from your wisdom -- as a Windows user going back to 2.0, having Macs in my life is always confusing, and my current job requires that I use one. This has removed a huge source of frustration. Now if only I can figure out how to deal with a Mac with a PC keyboard that has no Windows key… there aren’t enough keys in the right places to map command/control/option etc. to.
just setup on BigSur, and restarted… no change
Was struggling trying to get ctrl + left/right arrow to perform left word/right word in mac BIG Sur. You will have to unmap Mission Control ctrl left/right in System Preferences->Keyboard->Shortcuts.
Otherwise, the above worked well
Just tried the suggested edit to the DefaultKeyBinding file. For me, on a Mac mini M1 running 11.5.1 results are great except that some apps won’t work. Apparently they have their own key bindings.
Oh, same results when I either logout and log back in or reboot. We may be trying to get some windows-like behavior going but we don’t have to reboot to have our account configuration files read, just log in.
Just installed Karabiner — Elements and all the necessary rule and no love for me on MacOS Big Sur 11.2.3. I am, however, using a Logitech K860 which comes with its own software (Logi Options) for key reassignment. I have a feeling Logi Options is preempting Karabiner — Elements.
mosesvii’s suggestion about “Karabiner — Elements” is working great on latest version of Mac OS as of now. Installation and getting system security settings configured properly took a few minutes and was a bit confusing, but once I got it going it’s working a treat.
Works for me using Big Sur. Apps like Notes are not working.
It works for me on Big Sur except for the Messages app.
I tried what mosesvii suggested and It worked perfectly for me. 2019 iMac 27″ running Big Sur 11.0.1
For whatever reason I was having issues with the keybinding stuff. After looking at a YouTube vid I found what I think is a better solution. At least a more comprehensive one.
Google ‘Karabiner — Elements’and download it. It’s free… and works on my new M1 Mac Mini. Using the tool i was able to download loads of Windows keymappings at the click of a button.
I know i could learn the mac shortcuts, and will over time. But now having my Home and End button back, among other shortcuts, is great!
In the tool click the ‘Complex Modifications’ tab, then ‘Add rule’. In the new window, clicking the ‘Import more rules from the Internet’ button opens up a webpage with predefined key mappings. There are so many there. I found one called “Windows shortcuts on macOS”. Imported it, and enmabled the keys i wanted. No rebooting, no messing with Terminal.
I’m super happy :)
Seems like I gotta do this once a year, and every time the old tricks don’t work. This time terminal commands don’t lead to a text edit file opening up, like some other users.
I was able to do it without using terminal at all, though. I created a Text Edit file, pasted in the code Damien gave above, saved it as ‘DefaultKeyBinding.dict’(used Get Info, cmd-i to make sure it really was a .dict file not .rtf, as others have said), then placed that file in my hard drive>Library>KeyBindings. (You may need to make this folder, I think my earlier flailing around in Terminal did this. There is also a Library folder under my user name, using one or both seems to make no difference.)
Every time I do this it seems to work in fewer programs, though. I’m on Big Sur 11.2.2, and it doesn’t work in Stickies, Messages, Open Office, and probably more. Using moveToBeginningOfParagraph versus moveToBeginningOfLine seems to make no difference. I haven’t tried Sean’s suggestion of Hammer Spoon yet.
Same as Jam on Big Sur — make folder +file (text edit, save, and then delete extension from ‘Get Info’ menu) — but it works and I am so grateful! End key is my life.
Still works as of 20jan20 on Big Sur.
Had to create the folder and file. Thanks!
Here is a solution I wrote to deal with different apps, virtual machines, remote desktop, etc. Note: You have to install the awesome Hammerspoon Lua scripting framework, and tweak some config files. But it’s pretty comprehensive, and open source.
https://github.com/quickdraw6906/hammerspoon-pc
I can confirm that it works on Macbook Pro (16-inch, 2019) — Catalina 10.15.7.
Thank you so much for this post and thank you for all the comments. Using what @Rich wrote on 9/4/2020, I was able to make the Home and End keys work as I expect them to. And it works on Firefox. What a HUGE difference in reducing my stress level at the keyboard. And it works for Firefox and everything I’ve tested so far. I’m on Catalina 10.15.7.
I have been putting up with this nonsense for a couple of years. Thanks for putting an end to a very real struggle. So much happier now. Thanks very much for sharing this!
After trying to follow everything on here to no success, I found a website that had easy to follow instructions. Most importantly, my home and end keys work as I desire.
https://www.iexplain.org/remap-home-and-end-buttons-for-external-keyboard-on-mac/
Fire up your favorite terminal (you’re probably using iTerm2 like the rest of the world)
mkdir -p ~/Library/KeyBindings nano ~/Library/KeyBindings/DefaultKeyBinding.dict
The seasoned programmer could just go vi ~/Library/KeyBindings/DefaultKeyBinding.dict or more likely vim, but for the rest of us, nano works like a regular text editor.
In the empty file you just opened, copy and paste the following:
Having pasted it into the file, press Ctrl + X and answer with
y
when you get the question if you want to save.Well that’s it. Now you have successfully remapped the home and en button for macOS. You need to restart to make the changes happen.
Can I get additional clarification with how to get it working on Catalina 10.15.6? I don’t really understand the instructions that @emmap has posted above. For steps 1 & 2, my user already has read and write access to the file and folder, and for step 3, I’m not really sure what any of it means.
This also works well on Catalina, however I find that the page will still scroll up / down when these keys are pressed, even though the behaviour is now as expected.
Anybody know of a way to prevent this?
Thanks so much!
Now it works on Catalina 10.15.6:
1- given ownership to the user MyUser to the folder /Users/MyUser/Library/KeyBindings/ and to the file DefaultKeyBinding.dict chown MyUser /Users/MyUser/Library/KeyBindings/ chown MyUser /Users/MyUser/Library/KeyBindings/DefaultKeyBinding.dict
2- given to all users all rights to the folder /Users/MyUser/Library/KeyBindings/ and to the file DefaultKeyBinding.dict chmod 777 /Users/MyUser/Library/KeyBindings/ chmod 777 /Users/MyUser/Library/KeyBindings/DefaultKeyBinding.dict
3- then saved the file into ASCII format with CRLF line endings instead of LF.
@Lolo If you copied and pasted code from others on this webpage, your double-quote character could be wrong. Replace everything that looks like a double-quote with an actual double-quote. This has caused me problems many times when writing code.
Also, your command-* key mappings are really ctrl-* mappings because you are using the ‘^’ character at the beginning of the sequence. If you really want to use the command key, substitute the ‘^’ character with a ‘@’ character.
@Lolo
Try this: make sure your text in the .dict file is plain text and not rich text. To do this, go to Format > Make Plain Text and Save. Then killAll Finder and try again.
Either I’m dull or struggling to get this to work!
Here’s my code; a mix of Damien’s, Brian’s and suggestions from Sergio and Lance. Running Catalina 10.15.5:
Then after making sure it’s a .dict file, adding to KeyBindings, and then killall Finder in terminal, still no dice. What could I be doing wrong here?
For those having trouble, make sure you created an actual .dict file, as opposed to a .txt file. To verify this: Right Click the file > Get Info. Expand Name & Extension to remove the ‘.txt’ if it is present and save.
I also had to use “BeginningOfLine” instead of “BeginningOfParagraph” as user Brian mentions above.
Thank you so much for this!! As someone brand new to Terminal, I had difficulty following only the instructions on this page to get things working. In case this helps anyone else, here’s a step-by-step of how I did it in Catalina:
~mv /Documents/DefaultKeyBinding.dict ~/Library/KeyBindings/DefaultKeyBinding.dict
Thank you, on Catalina with Logitech K850 works fine with text editors, but Safari intercepts home/end keys to go begin/end of page, no matter if cursor is inside of a text box.
Awesone..! It saved my time and that was so frustating to work with documents. Thanks.
Thank you for this, it worked great
Thank you!!! This worked like a charm on 10.15.5. “touch” command didn’t open notepad for me. I instead used finder to navigate to the file and drag it to notepad manually.
I don’t think this is working on Catalina.
Works perfectly on Catalina — used Command instead of Ctrl though.
SAVED MY PRODUCTIVITY. Oh my, thanks!
WOW. What a difference it makes to have those keys remapped in a sane way. I gotta wonder what the heck apple was thinking. My guess is “Well, we only added those keys to keep that PC users happy. Let’s really mess with them. We don’t need to make them happy, we’ve got truckloads of brain-washed fanboy to keep up our User satisfaction numbers up”.
Can confirm that Damien’s code plus Evey’s file creation instructions works on macOS Catalina (Version 10.15.5). Thank you both!
Yay! Thanks!
[Insert lengthy, obscenity-laced vituperation over this and a number of other “natural” MacOS behaviors]
“3) A Notepad window will pop up. Copy-paste Damien’s code into that window and hit save. ”
On Catalina, this does not happen and I cannot find ANY way to save this script. Textapp and Script Writer REFUSE to save it where directed. I’m at the end of my wits here; HOW is this actually accomplished? I’m attempting to save, as suggested, in ~(home/dir) ~/Library/KeyBindings/Default/KeyBinding.dict, but every time i check the file in terminal, it’s empty. What, please, is going on?
THANNNNNNK YOU!!
WFH indeed… I googled again for a solution and reading the instructions I found I had created that file in the past (this issue has been annoying me long already) but it doesn’t seem to work. I have Catalina 10.15.4. Any hint?
Big thanks for this.
For those like me, who aren’t regular Terminal users and who don’t just intuitively know what “create a file… in your library with the following contents” means:
mkdir -p ~/Library/KeyBindings/
and hit enter Type/copy paste intouch ~/Library/KeyBindings/DefaultKeyBinding.dict
and hit enter Type/copy paste intouch ~/Library/KeyBindings/DefaultKeyBinding.dict
and hit enterAs other have said this is fantastic. Thank you!
This is huge!! Thanks!!
Wonderful! This WFH period has really forced me to use my work laptop (mac) as my daily driver (as opposed to a modified Ubuntu at work) and this HOME/END thing was driving me nuts.
You just saved me from hours of agony in quarantine! (MacOS 10.15.4)
Worked for me on Catalina. The default behaviour in Chrome was driving me nuts.
Many thanks!
Yayyy! Working perfectly in Catalina, and Jerry Baker’s suggestion to nuke Finder worked perfectly without a reboot.
Nice, works like a charm for High Sierra. By the way, restarting computer isn’t necessary. Restarting finder should be sufficient
command: killall Finder
Thanks!
This didn’t work for me on Mojave. I had to use BeginningOfLine instead of BeginningOfParagraph. Here is my file:
Would it be strange if I were to propose to you on the spot?
I’ve been using PC and Linux since 1997, and just got a Mac to get into iOS development. You saved my efficiency.
Yay! Working on MacOS High Sierra
Hey, thanks for this! However, I don’t see it working in some apps in Chrome. Any suggestions. — Eric
It has been SO hard to accept the loss of functionality of the Home/End keys after moving to Mac full time. What a blessing your tip/snippet is! Thanks, Damien!
-TW
You can denote the Cmd key with ⌘ (PLACE OF INTEREST SIGN, Unicode: U+2318, UTF-8: E2 8C 98).
Hope that helps.
Also good luck mapping the function key, caps lock (read up on that- a large amount of people want that).
I am a left-hand mouser and wanted cut/copy/paste functions with the right hand. Trouble is, you can’t map control+fn (for copy), nor shift+fn (for paste), which are the keys that map positionally on a PC keyboard (I’m talking for PC keyboards with 2 rows of three keys: Ins, Home, Pg UP / Del, End, Pg Down).
Another issue is when you are like me, doing lots of Windoz in a VM (Oracle Virtualbox) and remote desktop (Microsoft Remote Desktop for MacOS). There you need to pass different keys so everything works. Same with terminal apps.
Karabiner is the go-to tool for key remapping, but there are issues with Sierra (Karabiner-elements is the next thing, but still a work in progress.
So, I built something that works in all contexts (ok, almost all) using Hammerspoon, a superb tool for automation on the Mac: https://github.com/quickdraw6906/hammerspoon-pc/blob/master/config.lua
also works on Version Mac OS X 10.12.4 (16E195). Awesome thanks, I love it :-) Is there some more stuff how to use that? Would love if I can change all my favourite shortcuts in one place
This worked on the latest macOS as well. Thank you.
For words selection like in Windows can be used next rules:
Amazing! Works like a charm on latest el capitan version. Thanks!