element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Solved - Mis-Mapped Keyboards for RPi
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 11 replies
  • Subscribers 678 subscribers
  • Views 3201 views
  • Users 0 members are here
Related

Solved - Mis-Mapped Keyboards for RPi

Former Member
Former Member over 12 years ago

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. 1. The CapsLock is functional but the LED does not light
  2. 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.

  1. 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

  • Sign in to reply
  • Cancel
  • Former Member
    Former Member over 12 years ago

    My own reply.

     

    The LOCALE choice defines the language (LANG).  You are not given a choice of LAYOUT in the configuration process.

     

    Once you choose a KEYBOARD the next screen has the available LAYOUT based on the value in the /etc/default/keyboard file.  Every one of them should have "US" in the name.  If you see that this is true, then you do not have the "gb" problem.

     

    If not, you likely do not have the "us" LAYOUT despite what you entered for LOCALE.

     

    Chuck

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • skipcave
    skipcave over 12 years ago in reply to Former Member

    I have the exact same problem that Chuck describes. I bought my RPi from Newark/element14, along with the package including the GearHead KB1700U keyboard and a 4GB SD card with the Raspbian OS preloaded. I discovered the keyboard problem, found this thread, and started to fix the problem. Then I discovered that when I looked at the directories on the RPi, there WAS NO ETC directory! The only directories I found with the ls command were just Desktop, Documents, indiecity, python_games, and Scratch, along with the RPi logo as ocr_pi.jpg.  Where is the etc directory? I can't try Chuck's fix if I can't find the etc/default directory with the keyboard file in it.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to skipcave

    Skip,

       Are you putting a slash before etc, as in

        ls /etc

    That should find it.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • morgaine
    morgaine over 12 years ago

    You have a typo in your shutdown command --- the time argument should be "now", not "new".  Also, the flag "-h" means "halt", whereas a reboot would have been more useful so "-r" is probably more appropriate.  In other words,

     

    shutdown -r now

     

    would be better.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • skipcave
    skipcave over 12 years ago in reply to Former Member

    @ coder27 - I tried the slash. No luck.

     

    Here's the session:

     

    pi@raspberrypi - $ ls

    Desktop ocr_pi.png python_games

    pi@raspberrypi - $ ls - /ect

    ls: cannot access /ect: No such file or directory

     

    ??????

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • johnbeetem
    johnbeetem over 12 years ago in reply to skipcave

    Skip Cave wrote:

     

    @ coder27 - I tried the slash. No luck.

     

    Here's the session:

     

    pi@raspberrypi - $ ls

    Desktop ocr_pi.png python_games

    pi@raspberrypi - $ ls - /ect

    ls: cannot access /ect: No such file or directory

     

    ??????

     

    It's "/etc", not "/ect".

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to morgaine

    Morgaine,

     

    You are correct.  I am working on more detail but personal life is interfering.  In all of my preparation notes for that response above, I never used "new".  But there it is.  "now" is correct.

     

    Also "reboot now" I believe will work as well as "shutdown -r now".  Just an assumption here.

     

    Chuck

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to Former Member

    You don't need "now" if you use the reboot command.  A simple "sudo reboot" will effectively do the same thing as "sudo shutdown -r -time now"

     

    Also, while this is a nice guide for manually setting the keyboard layout, why not do it through the raspi-config that pops up on first boot?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • gdstew
    gdstew over 12 years ago in reply to Former Member

    You can also use "sudo raspi-config" at any time. I've used it a few times after the first boot and it works.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to Former Member

    btw, in Linux or Unix, the slash has two different usages, which may be confusing.

    It can be used as punctuation, to separate the names in a compound directory pathname,

    or it can be used by itself or at the start of a pathname to mean the root directory. 

    So, in the command

            sudo nano /etc/default/keyboard

    the first slash means the root directory, the 2nd and 3rd slashes are punctuation marks

    (or delimiters) that separate the directory "etc" from the directory "default" from the file "keyboard".

     

    Note that in other OSs, like DOS or VAX/VMS, the slash is used to indicate an option

    for the command, like

         DIR/FULL

    might indicate to show a "full" directory listing.  But Linux or Unix normally use the dash

    for that purpose.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube