I have a MacBook pro for work use, and just got my hands on an apple USB keyboard.

When I am in the terminal, using the external keyboard ONLY I receive weird characters when I hit the UP arrow key. For instance, hitting the up arrow either enters a "~" (tilda) character. I tried changing the keyboard settings, and after doing that I started getting garbage characters "]]&D]]" and the like (that's not the actual error - it's the sort of character output you get when using a box remotely with the shell not configured properly for arrow keys).

The weird thing though is that while doing this with the external keyboard, the macbook's built in keyboard has no issues, all arrow keys work just fine. So this seems to be entirely related to the external keyboard.

Does anyone have any ideas what could be going on or how it could be fixed?

  • What sort of USB keyboard? Does it have a US QWERTY layout?
    – Chris Page
    Jan 2 '13 at 20:56

It is possible that a little more detail would help answer this question. As it stands, I would approach this problem by trying to troubleshoot step-by-step, and here are some steps I would consider.

If you have access to a different Apple or other vendor's USB keyboard, attempt to use that to see if the problem recurs. It is possible that your particular keyboard and/or laptop USB ports have a problem.

I would check your terminal emulation type with:

$ printenv TERM

If it is not "xterm-256color" (the default for new windows in OS X's Terminal) then you may wish to consider setting your window to use that via Terminal's preferences. (This assumes you are using Terminal, and not an alternative, like iTerm.)

If you are using the "screen" utility or an SSH session, you may wish to try the same processes without them. If the problem repeats without them, you've gained some more information. If the problem doesn't repeat, then the configuration for those utilities or the interaction with your shell may be at issue, and you can look further into that.

Your tags indicate that Zsh might be in use. Determine if you have the same problem if you switch to bash (the default for OS X since Mac OS X 10.3 Panther) or another shell. A benefit of trying this that Bash and Zsh shouldn't share any or many configuration files. So, the possibility of a particular customized configuration for either shell being the culprit would be minimized.

If another shell doesn't have the same problem, you will need to determine whether the shell configuration or shell itself is the problem. If the shell you normally use has been customized, I'd back up and eliminate that customization before starting a new session. If the new session works, then it stands to reason there's a problem in your specific shell configuration.

You could also try the above steps with a fresh new OS X user account, which will inherit default settings from the localized user template for your language. This user account can be created and removed after testing via System Preferences > Users & Groups (as it is named in OS X Mountain Lion). This step would generally eliminate any other keyboard layouts that have been installed, as well as software that might modify keyboard behavior. Even if such software was installed for all users on the system, it is probably not set up as a Login Item for new users.


Assuming the keys actually work at all, the problem would seem to be that they generate unrecognized control sequences, although why this should happen on an Apple keyboard is beyond me.

My suggestion would be to grab USB Overdrive. You should be able to use this to map the arrow keys to the normal functions.


I just noticed I hadn't put in the ultimate fix. The problem ultimately appears to have been the keyboard. It worked in all other facets BUT the terminal. When I attached a different unit of the same type of keyboard to the same laptop, the issue went away. So for some reason the keyboard is generating an interrupt that is seen by the OS as an up arrow press, but the shell is not understanding it as such. I don't really understand how that can happen, but that's what it is doing. Thank you all for your great suggestions.

  • 1
    I'll be damned. I just discovered exactly the same problem. Plugged in a different Apple External Keyboard and the problem went away.
    – Avi Cherry
    Oct 4 '17 at 18:45
  • Crazy right? I can't believe it actually worked. Amazingly enough I've been using the good keyboard for years now with no problems.
    – Matthew
    Oct 5 '17 at 14:11

The Apple Keyboard sometimes throw F6 with Up arrow key. You might not notice the effect in other apps or generally in the OS. You can confirm this issue by launching an online keyboard testing utility (e.g. https://www.keyboardtester.com/)

Press Up arrow and see if F6 hits with it. If you have the same issue which brought me here then here are few fixes.

1) Plug out and Plug in the keyboard after some time.
2) Try to use a different USB Port to connect the keyboard.
3) Try cleaning the keyboard (Not recommended as people tried multiple brand new keyboards)
4) Restart the computer (Seriously)

5) If nothing works, Just install a free utility like (Karabiner-Elements) and map F6 to Up Arrow.

enter image description here

There is a better fix using Karabiner, (I've been using it) it involved practical mess around its configurations and time consuming. So if you do not use F6 for brightness etc. This might be helpful for you.

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.