Ubuntu 17.10键盘按键映射异常求助:英文(UK)布局无效
Hey there, let's work through this keyboard mapping problem you're facing. It's super frustrating when keys don't output what you expect—even after switching layouts—so let's break this down step by step.
First, Verify Your Active Keyboard Layout
Sometimes the system might show you're using the UK layout, but the actual active configuration could be out of sync. Run these commands to check and reset if needed:
Check current Xorg keyboard settings:
setxkbmap -queryYou should see output focused on these lines (make sure
layoutis set togb):layout: gb
variant: (empty)
options: (empty)If the layout isn't
gb, or even if it is, reset it to default to rule out glitches:setxkbmap -layout gb -variant ""Test your problematic keys right after running this to see if the issue clears up.
Check GNOME's input source setup (Ubuntu 17.10 uses GNOME by default):
gsettings get org.gnome.desktop.input-sources sourcesThis should return
[('xkb', 'gb')]if only the UK layout is active. If other layouts are listed, they might be interfering—you can remove extras via Settings > Region & Language.
Dig Into Key Mappings with xmodmap
You mentioned running xmodmap -pke | grep slash—let's use this to examine how your slash-related keys are mapped.
First, share the full output of that command here. For reference, a typical UK layout maps the slash (/) to shift+# (the key to the right of L), with keycode mappings looking something like:
keycode 51 = numbersign slash numbersign slash dead_grave dead_breve dead_grave dead_breve
If your output shows different values for the keycode tied to your problematic key, that's likely the root cause.
Check for Custom Keyboard Configurations
Custom xmodmap settings or Xorg config files might be overriding the system layout:
- Look for a
~/.Xmodmapfile in your home directory. If it exists, rename it temporarily (e.g.,mv ~/.Xmodmap ~/.Xmodmap.bak) and restart your session to test if the problem goes away. - Check
/etc/X11/xorg.conf.d/for custom keyboard configs (files like90-keyboard.conf). If you find any, back them up and remove them temporarily to rule out conflicts.
Next Steps to Narrow It Down
If none of the above fixes the issue, please share:
- The exact output of
xmodmap -pke | grep slash - The output of
setxkbmap -query - Which specific key(s) are behaving unexpectedly (e.g., pressing the key right of
Loutputs#instead of/when holding shift)
That extra detail will help pinpoint exactly where the mapping is going wrong.
内容的提问来源于stack exchange,提问作者Ots Wng

