I installed MacPorts on OS X 10.5 and I found out that when I connect to the computer using SSH and use mc - Midnight Commander - the HOME and END keys do not work.

I have to mention that I'm using putty and I am able to use the keyboard very well on Linux machines like Fedora, Ubuntu,...

Here is putty keyboard configuration (a configuration I found to be optimal over time):

  • Backspace key: 127
  • Home/End keys: Standard
  • Function keys: Xterm R6
  • Cursor keys: Normal
  • Numpad: normal
  • Terminal type string: xterm-color

I'm looking for a command line solution/script that does these changes, this make much easier to create a prepare OS script for configuring a new OS.


The keyboard mappings for home and end in Terminal.app are not direct, but you can fix them. To get them to work directly, go to Terminal -> Preferences... -> Settings screen -> Keyboard and then find the lines for these keys and click the edit button for them (or add them if they are missing for some reason).

Be careful to not have any leading or trailing spaces as well for these.

home key code:


end key code:


page-up key code:


page-down key code:




  • I wasn't able to enter the sequences because backslash is auto-translated to double-backslash (OS X 10.6). Also, I would prefer a script/command line for doing these settings (if possible). – sorin Mar 9 '10 at 6:52
  • @Sorin Strange, I am running OS 10.6 and that's the OS I did my screenshots with, but then again I made my profile on 10.5. It appears that typing in the control sequence into TextEdit and then doing a copy and paste into the field works fine. – Lara Dougan Mar 11 '10 at 7:10
  • Legend, thanks! PageUp and PageDown now work properly in vim :-) – Sonia Hamilton Dec 17 '13 at 4:17
  • 1
    \033 is entered by pressing the escape key – jlsecrest Jun 26 '14 at 7:52

The actual question was how to use Home and End keys with PuTTY when logged into OSX using ssh.

First, I changed the settings in the OSX Terminal.app preferences according to this link. It worked for me to fix Home and End keys for usage on desktop. However when logged into OSX remotely with PuTTY, Home and End keys still didn't work. So I modified PuTTY terminal as below:

Go to PuTTY configuration > Terminal > Keyboard
find "The function keys and keypad"
instead of
click Apply.

Your Home and End keys should work properly now on your PuTTY terminal when you are logged into OSX.

You can set and save different settings for your different sessions. When you login to other type machines you may use standard PuTTY setting.

  • Setting "Function keys and keypad" to "SCO" fixes the home/end keys, but unfortunately breaks the F-keys in Midnight Commander... – Vladimir Panteleev Sep 13 '15 at 1:02
  • This repairs Home and End but changes the Del key to Backspace. – cweigel Feb 6 '18 at 15:17

Hold down the shift key for Home/End PgUp/Pg down in Terminal.app in order to not let Terminal use these keys for the scrollback. This way (with shift) Terminal will pass the keys on to the application running in the window.


I had a similar problem after switching to the Mac. In OS X, Home and End take you to the start and finish of a document respectively. Think of them as Page Up and Page Down on steroids.

To do the equivalent to the Windows usage of Home and End, use Command+Left Arrow and Command+Right Arrow.

  • 1
    Sorry but this a different problem and is not related to the one specified to you. – sorin Jul 31 '09 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.