日期:2014-05-16  浏览次数:20685 次

Linux下 键盘输入竖线 问题解决。

自从a92用上arch linux后,一直在被玩,我始终无法输入“|”,这个竖杠杠,以及"\",这个斜的的杠杠,很郁闷,很多命令,很多输入都没法搞定,但是在 windows上确实正常的,邪门阿,a92就是邪门,咱不是个爱折腾的人,于是就忍了,用的时候咱就复制。
但是今天终于忍无可忍了,这真的是被玩,于是搜索键位,最后看到有人写关于xmodmap的文章,看了一通后,还是不明白,不过试着执行xmodmap, 然后又xmodmap --help ,xmodmap -pke,然后祭出星际译王(stardict),看各个键位的描述后,才了解,原来keycode 51 = backslash bar backslash bar backslash bar
也就是说,反斜杠"\" backslash 和"|" bar被分配给编号为51的按键,然后又看网上很多文章说只要把你的键码和对应的字符按照这个格式写道~/.xmodmaprc文件里面就可以了,但是遗 憾啊,怎么就没人说一下,怎么获得这个键码,老天爷,我键盘上又没标这个玩意。
算了,看了很多文章都无奈了,千篇一律,好像这些人天生就知道这个键码一样,只好老实的,抱着侥幸的,试探的心态去看看man xmodmap,哈哈,看到这么一段:
keycode NUMBER = KEYSYMNAME ...
The list of keysyms is assigned to the indicated keycode (which
may be specified in decimal, hex or octal and can be determined
by running the xev program). Up to eight keysyms may be
attached to a key, however the last four are not used in any
major X server implementation. The first keysym is used when
no modifier key is pressed in conjunction with this key, the
second with Shift, the third when the Mode_switch key is used
with this key and the fourth when both the Mode_switch and
Shift keys are used.

我乐了,嘿嘿,原来人家man page里面说的很清楚,运行xev就可以看到键码!大哥们,为啥翻译man page就不把这句翻译一下。

接下来就简单了,直接运行xev,然后按a92上标有"\","|"的键,看到什么?
KeyPress event, serial 33, synthetic NO, window 0x2400001,
root 0x9c, subw 0x0, time 7763337, (443,257), root 447,326),
state 0x0, keycode 94 (keysym 0x3c, less), same_screen YES,
XLookupString gives 1 bytes: (3c) "<"
XmbLookupString gives 1 bytes: (3c) "<"
XFilterEvent returns: False

KeyRelease event, serial 33, synthetic NO, window 0x2400001,
root 0x9c, subw 0x0, time 7763396, (443,257), root 447,326),
state 0x0, keycode 94 (keysym 0x3c, less), same_screen YES,
XLookupString gives 1 bytes: (3c) "<"
XFilterEvent returns: False

按下一个键,具体内容,然后释放一个键,又xxx,具体呢,我们看到里面有 keycode 94,哈哈,我爱死你了,原来你是94号。

这下就简单了,执行 xmodmap -e "keycode 94 = backslash bar backslash bar backslash bar",按照man page说,这句话是把94号键设定成反斜杠和竖线。

执行后,找个地方按a92的可爱的94号键(反斜杠键),哦,太好了,完美完美,漂亮的竖杠杠和性感的反斜杠如约而至!

然后呢,为了下次不用执行这句话,直接在~/xmodmaprc文件里面写入: keycode 94 = backslash bar backslash bar backslash bar。
重新加载gdm来看看,一切完美解决。