SOLUTION TO THE POORLY MAPPED US KEYBOARDS FOR THE RPi
QUICK VERSION:
When we downloaded the Distribution file, it came with a default parameter putting our location in Great Britain. Unless you know about it, confusion will reign because you will think you are configuring the keyboard correctly.
So for the Raspberry Pi you need to open the file “keyboard” and edit it.
sudo nano /etc/default/keyboard
will open the file and you just type over two characters in the line
XKBLAYOUT=”gb” to read XKBLAYOUT=”us”,
Ctrl X, Y and reboot. Then you can reconfigure the RPi.
Thanks to Mike Grasser.
######################################################################
DETAILED VERSION
US keyboards have a poor reputation with Raspbery Pi.
When we downloaded the Distribution file, it came with a default parameter putting our location in a preset place. When you fired up your RPi the very first time, your keyboard was set in Great Britain. Apparently, this is information will never be influenced by the locale settings nor is it changed by a normal set up. You can not change that without editing the keyboard file.
The LOCALE settings only choose the language of the commands; you can choose Spanish (“ES”) and the screen commands will appear in Spanish, it has no affect on the keyboard layout.
So how do we get to the keyboard default file?
First, just log in and accept the defaults.
Linux has a text editor, and in Wheezy the command is “nano”. The keyboard settings are in a file called "keyboard" (surprise), and it lies two sub folders down. The command to open it is
sudo nano /etc/default/keyboard
There are 23 files in the /etc/default directory (the command “ls” before the directory name will list the files).
Nano is the text editor so it opens the keyboard file. I will not define all the lines, but the one most important is the line
XKBLAYOUT=“gb” (that is the Great Britain link)
You can modify this by overtyping the “gb” with “us” (lower case) and delete “gb” so it reads
XKBLAYOUT=“us”
Then exit with control X.
It will ask if you want to save it, click on Y(es).
sudo shutdown –h new
will shut down the RPi or you can use Ctrl-Alt-Del to restart.
After start up it will be slow, but only the first time. When the config file shows up, highlight the keyboard line, use TAB to get to the <OK> line. After you choose your keyboard, you will be shown a new table of US layouts. My 86-key keyboard is not one of them but nearly any generic keyboard will work pretty well. I chose the Generic 102-key (international) PC, and at a later screen I chose the layout, English (US). Be careful with some of these layouts as they may type a character that is not expected. You will have to decode the whole keyboard to enter commands.
If you want you can view the keyboard file again, the changes should appear.
I learned this from Michael Grasser, I don’t have an email link but he does write on several forums. “Michael Grasser linux” would narrow it down.
It was d’fault of that hidden file preselecting a UK layout that screws up and wastes time for the US RPi users.
I am left with the following three tolerable character key errors.
- 1. The CapsLock is functional but the LED does not light
- 2. The “\” and “|” key to the left of the space bar (a duplicate of the key on the upper right) generates the “<” and ”>”
characters, respectively.
- 3. “Ins” key is wild, generating the repeating combination >[[2~ as long as it is held down.
Best to you all. And thank you Mike!
Chuck
^^^^^^^^^^^^^^
My choices
CHANGE/SET LOCALE
Choice en_US.UTF-8 UTF-8
This is stored in the default file /etc/default/locale as LANG=en_US.UTF-8.
CONFIGURE KEYBOARD
The following were my choices for a Gearhead 86-Key Mini Keyboard.
KEYBOARD MODEL
Generic 102-key (Intl) PC
KEYBOARD LAYOUT
English (US)
FILE: /etc/default/keyboard
XKBMODEL = “pc102”
XKBLAYOUT = “us”
And there is the rub!
Your configuration setting for Keyboard Locale makes no difference in the layout. Unless you correct this, your keyboard will have a few strange characters that show up. My keyboard exchanged the @ and “, for example, fixed with the"us" overtype. Unless you edit that keyboard file, your US keyboard will have errors.
Chuck




