How can I fix my keyboard layout?

14,499

Solution 1

I'll tell you what eventually worked best for me.

  1. Open the gnome preference "keyboard layout" pane
  2. Move the layout order, if you have more than one
  3. Delete all layouts except the default one (mine was a US layout)

The previous two steps have been suggested as fixes on their own (on the Ubuntu forums?). They did not work for me. I tried them together consecutively and this again did not work for me. Thus my next step.

  1. Press, "Reset to Defaults"
  2. Layout changes effectuated from both the layout pane and indicator now result in a change in layout.
  3. Of course, add layouts back before attempting to change to them. Use the preview function to find a layout that easily produces the diacritical marks you seek.

I think my problem was from the fact that some of the layouts had changed in name, at least that's my take considering that the layout names weren't exactly what I expected when reassigning them. Deleting my extra layouts and then assigning new ones from a fresh list seems to have circumvented my issues, that being that the layouts of my choice now point to existing layouts with names to match.

Solution 2

You should be able to run the following to reselect your keyboard.

sudo dpkg-reconfigure keyboard-configuration

If it doesn't stick, you'll probably need to change /etc/default/keyboard. I think I have your keyboard and my pertinent file shows the following, running through an old IBM clone 104 keyboard.

XKBMODEL="pc104"
XKBLAYOUT="us"
XKBVARIANT="intl"
XKBOPTIONS="terminate:ctrl_alt_bksp"

So do that with gksudo gedit /etc/default/keyboard or however kids are editing files these days. Read pertinent info here for what to plug in.

I see sudo udevadm trigger --subsystem-match=input --action=change is suggested elsewhere herein.

If that doesn't work, your layout is probably corrupt or just wrong, and I can't be sure what would help but I would try reinstalling xkb-data, iso-codes.

Perhaps updating your locale since language and layouts are intertwined. See this but something like:

dpkg-reconfigure locales 
update-locale LANG=en_US.UTF-8

I guess I should mention that I've made good use of "English International AltGr dead keys" layout, if you're looking for dead keys. I don't know what the /etc/default/keyboard file would reflect for this one but googling would surely bring an answer, but first try adding it via the Keyboard Layout pane. Warning, there seems to be a limit of 4 before you can't add any more.

Other than that I'd point you towards xmodmap. It's capable of overriding layout defaults. Let me know if any, or which ones help.

What languages are you writing other than English? Spanish (because of the ñ)? and?

Solution 3

I am not certain this will help you, but when I asked this question of a German co-worker of mine (who also uses Ubuntu) he sent me this link:

http://ubuntuforums.org/showthread.php?t=1654199&highlight=.Xmodmap

As I am unfamiliar with keyboard layout definitions, I can't be certain it will work for you but I thought I'd send it along just in case.

Best of luck in solving this!

Solution 4

I'm just wondering what happens if you modify or create a ~/.dmrc as in:

[Desktop]
Language=de_DE.UTF-8   # change to your default lang
Layout=de   nodeadkeys # change to your keyboard layout

And then run:

sudo udevadm trigger --subsystem-match=input --action=change

Source: Permanently change keyboard layout

Share:
14,499

Related videos on Youtube

Scott Severance
Author by

Scott Severance

My first Linux experience was in 1998 (via telnet into my university's server to read my email with PINE). I've run Linux on my own machines off and on since 1999 and exclusively since 2006. My first distro was Slackware, which I quickly broke. I then went back to Windows 95. After that, my friend helped me install Debian, which I used until I replaced that machine. I found Debian too difficult to install on my own, so I put Red Hat on my newer machine. At that time, yum didn't exist, and Red Hat only offered updates if I logged in to X as root, which I rarely did. So, it quickly became outdated, and OpenOffice 1.1 couldn't handle right-to-left text, which I needed for one of my university classes. So, I started using my Windows XP laptop most of the time. I couldn't install Linux on the laptop because the NTFS tools of the era couldn't resize my partition. After a couple of years, I decided to switch my Red Hat box to something more modern. I wanted to move away from the RPM package format, so I tried installing Debian again and once again found it too complicated to get all the features I needed. Then, I read about an up and coming Debian-based distro called Ubuntu that had just released their latest version. So, I installed 6.06 (Dapper Drake) and have used Ubuntu exclusively as my main OS all my machines since that time. I only boot into Windows a few times a year. I've tried a few other distros' live CDs, but so far have always decided that the benefits of those distros aren't significant enough for me to switch over. For the first many years, I used the command line most of the time, as early Linux GUIs weren't up to many basic tasks. These days, the GUI tools have made leaps and bounds and are quite usable. Nevertheless, I often prefer the command line for many tasks. I'm much more likely to use vim than Gedit. But, I quite appreciate GUI tools for a number of tasks--perhaps most tasks these days. SOreadytohelp

Updated on September 18, 2022

Comments

  • Scott Severance
    Scott Severance almost 2 years

    For a long time, I've had my keyboard configured to use the layout currently known as "English (international AltGr dead keys)." I like this layout because without any modifier keys, it's identical to the US English keyboard, but when I hold Right Alt I can get accented letters and other characters not available on a standard US English keyboard.

    In Oneiric, however, the layout is messed up. Right Alt+N produces "ñ" as expected. And another method works: Right Alt+`, E produces "è", also as expected. But there's no way to type "é", which is probably the accented letter I type the most. I expect Right Alt+A, E to do the trick. But instead of a dead key for the acute accent, it uses a method for combining characters to create the hybrid "́e". This hybrid looks like the proper "é" in some settings, but it isn't the same character and doesn't always work. (For example, in the text input box as I type this, it looks the same as the proper character, but when displayed on the site for all so see, it looks very wrong--at least on my machine.) Ditto for all other characters with an acute accent, though some are available directly as pre-composed characters: For example, Right Alt+I yields "í".

    How can I change the acute accent on the A key to a proper dead key? Perhaps the more general version of this is: How can I tweak my keyboard layout?

    Update

    I just tested this on my other machine, also running Oneiric, but upgraded from previous versions. I have no problems with the second machine. The problem machine was a fresh install of Oneiric, but I kept my old $HOME when I did the fresh install.

    Clarification

    Even if an answer doesn't address my specific examples, I would still accept it if it provided enough detail for me to find the layout and tweak it according to my needs.

    Major Update

    After working through the information gained through Jim C's and Chascon's helpful replies, I've learned something new: The problem isn't with the layout itself, but with the fact that the selected layout isn't being applied. When I look at the definition in /usr/share/X11/xkb/symbols/us of the layout I've been running for a long time, I found that the definition doesn't match what I get when I type. In addition, the keyboard layout dialog that's supposed to show the current layout looks different from the way the layout is defined in the file I mentioned, and matches what actually happens when I type.

    Following Jim C's suggestion, I created a new layout in /usr/share/X11/xkb/symbols/us containing some modifications to the layout I want. I can select my layout from the keyboard properties, and I can use in on the console following Chascon's post, but the layout I get when typing is unchanged.

    Apparently, there's a different layout defined somewhere that's overriding what I've set. Where is that layout hiding?

    This problem occurs in Unity (3D and 2D), but I was able to get the correct layout set in Xfce.

    In case it's relevant, this problem has occurred since I installed Oneiric fresh on this machine (though I preserved my $HOME). I don't recall whether this problem occurred before the reinstall.

    Also, in case it's relevant, I also run iBus so I can type Korean. I have a few difficulties with iBus, but I doubt they're related.

    • enzotib
      enzotib over 12 years
      Have you tried the sequence Right-Alt + ' + e ?
    • Scott Severance
      Scott Severance over 12 years
      Doesn't work. RightAlt + ' produces , not a dead key.
    • Panther
      Panther over 12 years
      Did you ever find a solution ?
    • Scott Severance
      Scott Severance over 12 years
      @bodhi.zazen: No. The problem still exists.
    • koni_raid
      koni_raid about 12 years
      Added Int. Keyboard with dead keys and pressing Right-Alt+e results in the letter è: The same with Right-Alt+a => á
    • Scott Severance
      Scott Severance about 12 years
      For me, RightAlt+e results in "€", which as I don't deal with euros isn't terribly valuable to me. But, I suspect that it's not going away as part of the layout since many people need easy access to €.
    • TRiG
      TRiG about 12 years
      RightAlt+4 is standard for € on most European keyboards. I suppose tying it to the E makes some sense.
  • Scott Severance
    Scott Severance about 12 years
    Thanks for your answer. However, it had no effect.
  • Scott Severance
    Scott Severance about 12 years
    I've made a discovery which changes the game significantly. See my updated question above.
  • Scott Severance
    Scott Severance about 12 years
    Good suggestion, but that setting was already on and toggling it didn't help.
  • Scott Severance
    Scott Severance about 12 years
    I had a .dmrc already, and it turns out that it was set to the wrong layout. I corrected it and ran your udevadm command. No dice. I rebooted, and still it didn't work.
  • Chris Browne
    Chris Browne about 12 years
    Just out of interest, does disabling ibus correct the issue? Just so we can isolate whether the problem has anything to do with ibus.
  • Scott Severance
    Scott Severance about 12 years
    It has no effect.
  • Scott Severance
    Scott Severance about 12 years
    The bounty period has now ended. My problem hasn't been solved, but since this post solved my first question (which turned out to be irrelevant), I'm awarding the bounty. But, the problem remains unsolved.
  • Chris Browne
    Chris Browne about 12 years
    What happens if you choose your layout using sudo dpkg-reconfigure keyboard-configuration?
  • Scott Severance
    Scott Severance about 12 years
    I've done that already. It sets the correct layout on the console, but doesn't help from within Unity.
  • Chris Browne
    Chris Browne about 12 years
    OK, I'm at a loss then. Sorry I couldn't be of more help.
  • Jim C
    Jim C about 12 years
    Thanks, Scott, that was kind of you. I hope someone can help figure out what is overriding your keyboard layout choice.
  • Scott Severance
    Scott Severance over 11 years
    At long last! Thanks a lot. This finally worked.