Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

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

3 Answers 3

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
xterm-256color

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.

share|improve this answer

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.

share|improve this answer
up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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