add files about keymaps and xmodmap

This commit is contained in:
geekard
2012-11-19 20:58:04 +08:00
parent 6642e173f9
commit 411a288513
17 changed files with 3033 additions and 88 deletions

7
Zim/Utils/grub.txt Normal file
View File

@@ -0,0 +1,7 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2012-11-09T21:20:10+08:00
====== grub ======
Created Friday 09 November 2012

View File

@@ -1,77 +0,0 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2012-03-18T16:10:36+08:00
====== xmodmap ======
Created Sunday 18 March 2012
http://lins05.mysmth.net/2011/04/24/67/
===== Linux改键利器:Xmodmap 的简单教程 =====
Linux改键利器:Xmodmap 的简单教程 适用对象:
* Emacs用户,需要交换 CapsLock 和 left Ctrl的人
* 其他有改键需要的人
* 喜欢瞎折腾的人
对于一般用户,如果没有特殊的需要,可能从未听说过`Xmodmap`这个程序。即使听说,也跟 xinit/Xsession/X 一样蒙着一层神秘的面纱。今天,我由于迫切地想把左边的windows键给屏蔽掉(原因就说来话长了),Goolge了半天没有找到一个现成的答案,唯一的线索是可以使用xmodmap来实现。 最后不得不一行行地读 xmodmap的man,二十分钟之后,发现原来如此简单。心血来潮之际,写一个简单的教程,以xb心中的得意之情,同时以后也可以作为自己和别人的参考。
===== 提出问题: =====
如何交换CapsLock和左边的Ctrl键? 答:
xmodmap -e "remove **lock** = Caps_Lock" ;
xmodmap -e "remove **control** = Control_L";
xmodmap -e "add control = Caps_Lock";
xmodmap -e "add lock = Control_L"
后面的内容是具体的教程,前面是提供给只需要一个做法而不需要了解具体的原理的。如果你属于此类,完全可以不看后面的内容了。 不过原理很简单,而且一旦学会,改键就跟grep一个正则表达式差不多简单。
===== 分析问题: =====
看到这里的人,应该是有耐心理解下面三个概念的: keycode/keysym/modifier 这三个概念是键盘相关的、层次从低到高的三个名词。
===== keycode– =====
一般的键盘上有102或者105键,每一个键被按下时会产生一个特有类型、主板能够分辨的电信号,传输给主板,主板给不同的电信号定下不同的编号,这就是所谓的keycode。 这些电信号是__在生产键盘时就定死了的__,比如左边的Ctrl键产生的keycode是37。CapsLock键产生的keycode是66。 要查找某个按键的keycode,可以在term中用__`xev`__程序来查看。xev使用很简单,它运行时,你按下一个键,term中就会显示这个键的许多信息,其中就有keycode。 这些keycode是硬件决定的,你我无法改变。总之记住,__一个按键产生的keycode是不可能在软件中改变的__。
===== keysym– =====
操作系统按照统一的规范,给不同的keycode映射为不同的含义,这个映射后的含义的术语就叫做keysym。比如你在emacs中打字时按下一个s键。屏幕上出现一个`s`,而不是出现一个`b`,是因为:系统接收到s的keycode–我用xev查了下,keycode(s) = 39, 按照默认的标准,39对应于字母`s`,于是就这个`s`显示在屏幕上。 (当然,更严谨地、更准确地说,应该是把`s`这个字母作为输入传递给Emacs,emacs再把这个字母插入到当前的文件中的。) 这里,keycode是39,其对应的符号,术语叫keysym,即`key symbol`,就是字母`s`。 同理,你按下键盘上的’b'(keycode(b) = 56),它的(默认的)keysym就是字母`b`。 系统给一个keycode分配的keysym不只一个。对于一个字母键,至少两个。第一个是单独按下这个键时对应的一,第二个是shift和这个键同时按下时的keysym。 键盘上,还有另外一类按键,它们单独按下时,一般没有任何意义,只有与其他的按照一直按下时是,才会产生一些特殊的效果,比如Ctrl、Shift、win键;它们实现的效果,称为modifier。
Modifier–修饰符
“修饰符”的修饰二字很好解释,你按下s,是打一个字母s,你按下Ctrl+s,大部分软件里,会保存当前文件;你按下Shift+s,是打另一个字母S。总之是, “改变一个键的本来含义“。因为`modify`本来就是修改的意思。 在term里输入命令`xmodmap`,会出现以下内容
shift Shift_L (0×32), Shift_R (0×3e) lock control Control_R (0×25), Caps_Lock (0×42), Control_R (0×69) mod1 Alt_L (0×40), Alt_R (0×6c), Meta_L (0xcd) mod2 Num_Lock (0×4d) mod3 mod4 Super_L (0×85), Super_R (0×86), Super_L (0xce), Hyper_L (0xcf) mod5 ISO_Level3_Shift (0×5c), Mode_switch (0xcb) 左边那一列,就是系统中所有的`modifier`。 系统会把一些默认的keysym解释为modifier,比如,默认情况下,你按下Shift + s, 屏幕上出现大写的S,整个过程其实是:
系统收到Shift键和s键的keycode
系统处理 keycode–>keysym 的映射: shift的keycode被映射到`SHIFT_L`这个keysym;s的keycode被映射到`s`这个keysym
系统发现,SHIFT_L这个keysym被定义为shfit这个modifier。
`s`被shift这个modifier给修饰了,修饰的结果是变成了大写的S。
基本概念讲完了,那么,`xmodmap`是如何帮我们实现`改键`的呢? 可以看到,从按下一个键到最后,有两个层次的映射过程:
第一层: keycode–>keysym
第二层: keysym –> modifier
因此,我们可以通过两种方法来实现改键。以
第一步:
目标:把键盘上的s和b键交换位置
先查询keycode: keycode(s) = 37 keycode(b) = 56
xmodmap -e "keycode 37 = b" xmodmap -e "keycode 56 = s" 这样,就交换了 s/b 这两个键的位置了! 注意,在你执行了第一条语句之后,s立刻被重新映射到b了,那么你第二条语句中的`s`怎么打出来呢? 两个方法: i) 从别处粘贴一个过来 ii)见最后的`xmodmap执行命令的三种方式` 注意:这个方法只能交换一般的keysym,那些定义为Modifier的键,就不能简单地用这个方式交换。因为: 当一个keysym被定义为modifier,那么,本质上是在 keycode–>modifier之间建立起了一个映射。因此,即使你改变了它的keycode–>keysym关系,也不起作用! 也就是说:当你要把一个键定义一个modifier时,你只能把它的keycode对应的keysym定义为modifier,从而达到目的。但这之后,即使keycode映射到别的keysym了,这个keycode仍然是一个modifier。 因此,如果要交换CapsLock和Ctrl这两个键,只需要做两件事:
把`Caps_Lock`这个keysym定义为`control`这个modifer
把`Control_L`这个keysym定义为`Caps_Lock`这个modifier (Control_L是左Ctrl键的默认keysym)
第二步: 交换 Caps_Lock和 左边的Ctrl
先把CapsLock这个keysym映射到control这个modifier:
xmodmap -e "remove lock = Caps_Lock" xmodmap -e "add control = Caps_Lock" 因为一个keysym不能同时映射到两个modifier,因此,我们需要先用remove,把Caps_Lock这个keysym与lock这个modifier的映射关系删除。然后,再把Caps_Lock这个keysym映射到Control这个modifier。 remove和add的的语法是:
remove/add modifier_name = keysym_name 此时,你可以试一下,看看是否已经产生效果了? 同样,再把左边的Ctrl键映射到CapsLock:
xmodmap -e "remove control = Control_L" xmodmap -e "add Caps_Lock = Control_L" xmodmap执行命令的三种方式: 1) xmodmap -e "do somthing" 是让xmodmap执行后面的一条句子。但这样一次只能执行一条。 2) 你也可以先输入 `xmodmap -`,然后回车,然后输入任意多句子,每输入一条就用回车分隔,最后用Ctrl+D结束输入。 3) 把remove xxx = yyy 这些句子都写到一个文件里。一般是~/.Xmodmap。然后用 `xmodmap ~/.Xmodmap`执行。 这样的好处是,在启动时的某个脚本里加一行命令,就不用每次重启都手动地改键了。 第三层:可逆的改键: 不难看出,运行了上面方法二中的四句命令之后,如果想要改回来的话,还需要另外写四句。以下六句可以实现这 样的效果,第一次运行,是交换CapsLock和Ctrl_L,第二次运行,又会再交换回来。
remove lock = Caps_Lock remove control = Control_L keysym Caps_Lock = Control_L keysym Control_L = Caps_Lock add lock = Caps_lock add control = Control_L 为什么会有这个效果呢?是因为多了中间两句话。
keysym Caps_Lock = Control_L –keycode 66 = Control_L keysym Control_L = Caps_Lock –keycode 37 = Caps_Lock “keysym A = B” 这个句子相当于: 把所有原来映射到A的keycode重新映射到 B。比如,有一个键Q,他的keycode原来对应的keysym是A,那么,在执行了上面语句之后,这个键Q的keycode对应的keysym就是B 因此, keysym Caps_Lock = Control_L –把Cap键映射到Control_L这个keysym keysym Control_L = Caps_Lock –把Ctrl键映射到Caps_Locks这个keysym
转载请注明出处。 可能有不正确的 地方,本文不负任何责任。

View File

@@ -0,0 +1,7 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2012-11-19T19:07:10+08:00
====== 键盘布局和按键映射 ======
Created Monday 19 November 2012

View File

@@ -0,0 +1,323 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2012-11-19T16:13:12+08:00
====== keymaps ======
Created Monday 19 November 2012
KEYMAPS(5) KEYMAPS(5)
===== NAME =====
keymaps - keyboard table descriptions for **loadkeys** and **dumpkeys**
===== DESCRIPTION =====
These files are used by loadkeys(1) to modify the __translation tables__
used by the __kernel keyboard driver__ and generated by **dumpkeys(1)** from
those translation tables.
The format of these files is vaguely similar to the one accepted by
**xmodmap(1).** The file consists of charset or key or string definition
lines interspersed with comments.
Comments are introduced with ! or # characters and continue to the end
of the line. Anything following one of these characters on that line is
ignored. Note that comments need not begin from column one as with
xmodmap(1).
The syntax of keymap files is line oriented; a complete definition must
fit on a single logical line. Logical lines can, however, be split into
multiple physical lines by ending each subline with the backslash char‐
acter (\).
===== INCLUDE FILES =====
A keymap can include other keymaps using the syntax
include "pathname"
===== CHARSET DEFINITIONS =====
A character set definition line is of the form:
charset "iso-8859-x"
It defines how following **keysyms** are to be interpreted. For example,
in iso-8859-1 the symbol mu (or micro) has code 0265, while in
iso-8859-7 the letter mu has code 0354.
===== COMPLETE KEYCODE DEFINITIONS =====
Each complete key definition line is of the form:
keycode keynumber = keysym keysym keysym...
**keynumber** is the internal identification number of the key, roughly
equivalent to the __scan code__ of it. keynumber can be given in decimal,
octal or hexadecimal notation. Octal is denoted by a leading zero and
hexadecimal by the prefix 0x.
在虚拟终端模式下,可以通过__showkey命令__来查看某个按键的keycode。通过
__dumpkeys__(不加任何参数,或-f参数)来查看当前keycode与keysym的绑定。
Each of the keysyms represent **keyboard actions**, of which up to __256__ can
be bound to a single key. The actions available include outputting
character codes or character sequences, switching consoles or keymaps,
booting the machine etc. (The complete list can be obtained from dump‐
keys(1) by saying __dumpkeys -l__ .)
keyboard actions包括打印字符、切换终端、命令行编辑、启动系统等,具体
可以使用 dumpkeys -l命令来查看
Each keysym may be prefixed by a '+' (plus sign), in wich case this
keysym is treated as a "letter" and therefore affected by the "Cap‐
sLock" the same way as by "Shift" (to be correct, the CapsLock __inverts__
the Shift state). The ASCII letters ('a'-'z' and 'A'-'Z') are made
CapsLock'able by default. If Shift+CapsLock should not produce a lower
case symbol, put lines like
keycode 30 = +a A
in the map file.
Which of the actions bound to a given key is taken when it is pressed
depends on __what modifiers are in effect__ at that moment. The keyboard
driver supports **9 modifiers**. These modifiers are labeled (completely
arbitrarily) Shift, AltGr, Control, Alt, ShiftL, ShiftR, CtrlL, CtrlR
and CapsShift. Each of these modifiers has an associated weight of
power of two according to the following table:
modifier weight
Shift
1
AltGr
2
Control
4
Alt
8 //实际使用时,不使用16-256,故不区分L和R,只有Shift, Ctrl和Alt。
ShiftL
16
ShiftR
32
CtrlL
64
CtrlR 128
CapsShift 256
The effective action of a key is found out by __adding up the weights of__
__ all the modifiers in effect__. By default, no modifiers are in effect, so
action number **zero**, i.e. the one in the first column in a key defini‐
tion line, is taken when the key is pressed or released. When e.g.
Shift and Alt modifiers are in effect, action number nine (from the
10th column) is the effective one.
Changing the state of what modifiers are in effect can be achieved by
__binding appropriate key actions to desired keys(将keycode与key actions绑定)__.
For example, binding
the symbol Shift to a key sets the Shift modifier in effect when that
key is pressed and cancels the effect of that modifier when the key is
released. (也就是说将Shift与某个keycode代表的按键绑定。)Binding
AltGr_Lock to a key sets AltGr in effect when the key
is pressed and cancels the effect when the key is pressed again. (__By__
__ default Shift, AltGr, Control and Alt are bound to the keys that bear a__
__ similar label; AltGr may denote the right Alt key.__)。缺身情况下,Shift,Control
Alt分别于键盘上同一个标示的按键绑定。
Note that you should be very careful when binding the modifier keys,
otherwise you can end up with an unusable keyboard mapping. If you for
example define a key to have Control in its first column and leave the
rest of the columns to be VoidSymbols, you're in trouble. This is
because pressing the key puts Control modifier in effect and the fol‐
lowing actions are looked up from the fifth column (see the table
above). So, when you release the key, the action from the fifth column
is taken. It has VoidSymbol in it, so nothing happens. This means that
the **Control modifier is still in effect, although you have released the**
** key.** Re-pressing and releasing the key has no effect. To avoid this,
__you should always define all the columns to have the same modifier sym‐__
__ bol.__ There is a handy short-hand notation for this, see below.
keysyms can be given in decimal, octal, hexadecimal, unicode or sym‐
bolic notation. 最常用同时也最具可移植性的是**符号化代表**(symbolic notation),这些
符号名称可以被loadkeys命令识别。
The numeric notations use the same format as with
keynumber. Unicode notation is "U+" followed by four hexadecimal dig‐
its. The __symbolic notation__ resembles that used by xmodmap(1). Notable
differences are the number symbols. The numeric symbols '0', ..., '9'
of xmodmap(1) are replaced with the corresponding words 'zero', 'one',
... 'nine' to avoid confusion with the numeric notation.
It should be noted that using numeric notation for the keysyms is
highly unportable as the key action numbers may vary from one kernel
version to another and the use of numeric notations is thus strongly
discouraged. They are intended to be used only when you know there is a
supported keyboard action in your kernel for which your current version
of loadkeys(1) has no symbolic name.
There is a number of short-hand notations to add readability and reduce
typing work and the probability of typing-errors.
First of all, you can give __a map specification line__, of the form
keymaps 0-2,4-5,8,12
to indicate that the lines of the keymap will not specify all 256 col‐
umns, but only the indicated ones. (In the example: only the plain,
Shift, AltGr, Control, Control+Shift, Alt and Control+Alt maps, that
is, 7 columns instead of 256.这意味着Conrolt_L, Control_R等不再使用。
具体可以参考/usr/share/kbd/keymaps/i386/qwerty/us.map.gz)
When no such line is given, the keymaps 0-M will be defined, where M+1 is the maximum number of entries found
in any definition line.
Next, you can leave off any __trailing__ VoidSymbol entries from a key def‐
inition line. __注意必须是尾部的VoidSymbol.__ VoidSymbol denotes a keyboard
action which produces no
output and has no other effects either. For example, to define key num‐
ber 30 to output **'a' unshifted**, 'A' when pressed with Shift and do
nothing when pressed with AltGr or other modifiers, you can write
keycode 30 = a A
instead of the more verbose
keycode 30 = a A VoidSymbol VoidSymbol \
VoidSymbol VoidSymbol VoidSymbol ...
For added convenience, you can usually get off with still more terse
definitions. **If you enter a key definition line with only and exactly**
** one action code after the equals sign, it has **__a special__** meaning.**
**也就是说,当按键定义行只指定了一个action code时,该action是有特殊含义的。**
** 如果该action code代表非字符,则该action会被默认在所有column上重复(这也是**
pe**rsonal.map文件中的用法 **__keycode 56 = Control__**)。但是如果**
** 该action是字符,则相应column对应的action由modifier确定。** If the
code (numeric or symbolic) is not an ASCII letter, it means the code is
__implicitly replicated__ through all columns being defined. If, on the
other hand, the action code is an ASCII character in the range 'a',
..., 'z' or 'A', ..., 'Z' in the ASCII collating sequence, the follow‐
ing definitions are made for the different modifier combinations, pro‐
vided these are actually being defined. (The table lists the two pos‐
sible cases: either the single action code is a lower case letter,
denoted by 'x' or an upper case letter, denoted by 'Y'.)
modifier symbol
none x (小写字符) Y(大写字符)
Shift X y
AltGr x Y
Shift+AltGr X y
Control Control_x Control_y
Shift+Control Control_x Control_y
AltGr+Control Control_x Control_y
Shift+AltGr+Control Control_x Control_y
Alt Meta_x Meta_Y
Shift+Alt Meta_X Meta_y
AltGr+Alt Meta_x Meta_Y
Shift+AltGr+Alt Meta_X Meta_y
Control+Alt Meta_Control_x Meta_Control_y
Shift+Control+Alt Meta_Control_x Meta_Control_y
AltGr+Control+Alt Meta_Control_x Meta_Control_y
Shift+AltGr+Control+Alt Meta_Control_x Meta_Control_y
===== SINGLE MODIFIER DEFINITIONS =====
All the previous forms of key definition lines always define __all__ the
M+1 possible modifier combinations being defined, whether the line
actually contains that many action codes or not(loadkeys会自动补充没有指定的column).
There is, however, a variation of the definition syntax for __defining only single actions to__
__ a particular modifier combination of a key.__ This is especially useful,
if you load a keymap which doesn't match your needs in only some modi‐
fier combinations, like AltGr+function keys. You can then make a small
local file redefining only those modifier combinations and loading it
after the main file. The syntax of this form is:
{ plain | <modifier sequence> } keycode keynumber = keysym
, e.g.,
**plain** keycode 14 = BackSpace
control alt keycode 83 = Boot
alt keycode 105 = Decr_Console
alt keycode 106 = Incr_Console
Using "plain" will define only the base entry of a key (i.e. the one
with no modifiers in effect) without affecting the bindings of other
modifier combinations of that key.
===== STRING DEFINITIONS =====
In addition to comments and key definition lines, a keymap can contain
string definitions. These are used to define what each __function key(如F1-F12,__
可以参考dumpkeys命令的输出__)__
action code sends. The syntax of string definitions is:
string keysym = "text"
text can contain literal characters, octal character codes in the for‐
mat of backslash followed by up to three octal digits, and the three
escape sequences \n, \\, and \", for newline, backslash and quote,
respectively.
===== COMPOSE DEFINITIONS(获得注音字符,很少使用) =====
Then there may also be compose definitions. They have syntax
compose 'char' 'char' to 'char'
and describe how two bytes are combined to form a third one (when a
dead accent or compose key is used). This is used to get accented let‐
ters and the like on a standard keyboard.
===== ABBREVIATIONS =====
Various abbreviations can be used with kbd-0.96 and later.
__strings as usual__
Defines the usual values of the strings (but not the keys they
are bound to).
compose as usual for "iso-8859-1"
Defines the usual compose combinations.
To find out what __keysyms__ there are available for use in keymaps, use
the command
dumpkeys --long-info //打印keymaps文件中可以使用的符号名称。
Unfortunately, there is currently no description of what each symbol
does. It has to be guessed from the name or figured out from the kernel
sources.
===== EXAMPLES =====
(Be careful to use a keymaps line, like the first line of `dumpkeys`,
or "keymaps 0-15" or so.)
The following entry exchanges the left Control key and the Caps Lock
key on the keyboard:
keycode 58 = Control
keycode 29 = Caps_Lock
Key number 58 is normally the Caps Lock key, and key number 29 is nor‐
mally the Control key.
The following entry sets the Shift and Caps Lock keys to behave more
nicely, like in older typewriters. That is, pressing Caps Lock key once
or more sets the keyboard in CapsLock state and pressing either of the
Shift keys releases it.
keycode 42 = Uncaps_Shift
keycode 54 = Uncaps_Shift
keycode 58 = Caps_On
The following entry sets the layout of the edit pad in the enhanced
keyboard to be more like that in the VT200 series terminals:
keycode 102 = Insert
keycode 104 = Remove
keycode 107 = Prior
shift keycode 107 = Scroll_Backward
keycode 110 = Find
keycode 111 = Select
control alt keycode 111 = Boot
control altgr keycode 111 = Boot
Here's an example to bind the string "du\ndf\n" to the key AltGr-D. We
use the "spare" action code F100 not normally bound to any key.
altgr keycode 32 = F100
string F100 = "du\ndf\n"
===== SEE ALSO =====
loadkeys(1), dumpkeys(1), showkey(1), xmodmap(1)
24 April 1998 KEYMAPS(5)

View File

@@ -0,0 +1,482 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2012-11-19T16:45:20+08:00
====== dumpkeys ======
Created Monday 19 November 2012
**#dumpkeys** //打印当前kernel终端驱动程序使用的键盘映射表,注意:配置文件为__/etc/vconsole.conf,__下面的输出的内容其配置来源于该文件。
__// $cat /etc/vconsole.conf__
__// KEYMAP=personal__
__//而personal是位于/usr/share/kbd/keymaps/i386/qwerty/personal.map.gz文件。__
keymaps 0-2,4-6,8-9,12 //每个按键(keycode)最多绑定9个keysyms.
//根据**dumpkeys -l**的如下输出:
Recognized modifier names and their column numbers:
shift 1
altgr 2
control 4
alt 8
shiftl 16
shiftr 32
ctrll 64
ctrlr 128
capsshift 256
//可知kernel没有使用16以后的modifier,所以__不区分shiftl, shiftr,统一使用shift(ctrl类似)__。
keycode 1 = Escape
alt keycode 1 = Meta_Escape
shift alt keycode 1 = Meta_Escape
control alt keycode 1 = Meta_Escape
keycode 2 = one exclam
alt keycode 2 = Meta_one
shift alt keycode 2 = Meta_exclam
keycode 3 = two at at nul nul
alt keycode 3 = Meta_two
shift alt keycode 3 = Meta_at
control alt keycode 3 = Meta_nul
keycode 4 = three numbersign
control keycode 4 = Escape
alt keycode 4 = Meta_three
shift alt keycode 4 = Meta_numbersign
keycode 5 = four dollar dollar Control_backslash
alt keycode 5 = Meta_four
shift alt keycode 5 = Meta_dollar
control alt keycode 5 = Meta_Control_backslash
keycode 6 = five percent currency Control_bracketright
alt keycode 6 = Meta_five
shift alt keycode 6 = Meta_percent
keycode 7 = six asciicircum
control keycode 7 = Control_asciicircum
alt keycode 7 = Meta_six
shift alt keycode 7 = Meta_asciicircum
keycode 8 = seven ampersand braceleft Control_underscore
alt keycode 8 = Meta_seven
shift alt keycode 8 = Meta_ampersand
control alt keycode 8 = Meta_Control_underscore
keycode 9 = eight asterisk bracketleft Delete
alt keycode 9 = Meta_eight
shift alt keycode 9 = Meta_asterisk
control alt keycode 9 = Meta_Delete
keycode 10 = nine parenleft bracketright
alt keycode 10 = Meta_nine
shift alt keycode 10 = Meta_parenleft
keycode 11 = zero parenright braceright
alt keycode 11 = Meta_zero
shift alt keycode 11 = Meta_parenright
keycode 12 = minus underscore backslash Control_underscore Control_underscore
alt keycode 12 = Meta_minus
shift alt keycode 12 = Meta_underscore
control alt keycode 12 = Meta_Control_underscore
keycode 13 = equal plus
alt keycode 13 = Meta_equal
shift alt keycode 13 = Meta_plus
keycode 14 = Delete
alt keycode 14 = Meta_Delete
shift alt keycode 14 = Meta_Delete
control alt keycode 14 = Meta_Delete
keycode 15 = Tab
shift keycode 15 = Meta_Tab
alt keycode 15 = Meta_Tab
control alt keycode 15 = Meta_Tab
keycode 16 = q
keycode 17 = w
keycode 18 = e
keycode 19 = r
keycode 20 = t
keycode 21 = y
keycode 22 = u
keycode 23 = i
keycode 24 = o
keycode 25 = p
keycode 26 = bracketleft braceleft
control keycode 26 = Escape
alt keycode 26 = Meta_bracketleft
shift alt keycode 26 = Meta_braceleft
keycode 27 = bracketright braceright asciitilde Control_bracketright
alt keycode 27 = Meta_bracketright
shift alt keycode 27 = Meta_braceright
control alt keycode 27 = Meta_Control_bracketright
keycode 28 = Return
alt keycode 28 = Meta_Control_m
__keycode 29 = Alt__
//注意:通过showkeys可以查处__keycode 29 对应空格左边的Alt,而keycode 100 对应空格__
//右边的Alt,通过将它们都与Alt绑定,是这两个键具有相同功能。Ctrl和Shift类似。(这其实
是personal.map.gz文件配置的)
keycode 30 = a
keycode 31 = s
keycode 32 = d
keycode 33 = f
keycode 34 = g
keycode 35 = h
keycode 36 = j
keycode 37 = k
keycode 38 = l
keycode 39 = semicolon colon
alt keycode 39 = Meta_semicolon
shift alt keycode 39 = Meta_colon
keycode 40 = apostrophe quotedbl
control keycode 40 = Control_g
alt keycode 40 = Meta_apostrophe
shift alt keycode 40 = Meta_quotedbl
keycode 41 = grave asciitilde
control keycode 41 = nul
alt keycode 41 = Meta_grave
shift alt keycode 41 = Meta_asciitilde
__keycode 42 = Shift__
keycode 43 = backslash bar
control keycode 43 = Control_backslash
alt keycode 43 = Meta_backslash
shift alt keycode 43 = Meta_bar
keycode 44 = z
keycode 45 = x
keycode 46 = +c +C cent Control_c Control_c Control_c Meta_c Meta_C Meta_Control_c
keycode 47 = v
keycode 48 = b
keycode 49 = n
keycode 50 = m
keycode 51 = comma less
alt keycode 51 = Meta_comma
shift alt keycode 51 = Meta_less
keycode 52 = period greater
alt keycode 52 = Meta_period
shift alt keycode 52 = Meta_greater
keycode 53 = slash question
control keycode 53 = Control_underscore
shift control keycode 53 = Delete
alt keycode 53 = Meta_slash
shift alt keycode 53 = Meta_question
__keycode 54 = Shift__
keycode 55 = KP_Multiply
__keycode 56 = Control__
keycode 57 = space
control keycode 57 = nul
alt keycode 57 = Meta_space
shift alt keycode 57 = Meta_space
control alt keycode 57 = Meta_nul
keycode 58 = Caps_Lock
keycode 59 = F1 F13 Console_13 F25
alt keycode 59 = Console_1
control alt keycode 59 = Console_1
keycode 60 = F2 F14 Console_14 F26
alt keycode 60 = Console_2
control alt keycode 60 = Console_2
keycode 61 = F3 F15 Console_15 F27
alt keycode 61 = Console_3
control alt keycode 61 = Console_3
keycode 62 = F4 F16 Console_16 F28
alt keycode 62 = Console_4
control alt keycode 62 = Console_4
keycode 63 = F5 F17 Console_17 F29
alt keycode 63 = Console_5
control alt keycode 63 = Console_5
keycode 64 = F6 F18 Console_18 F30
alt keycode 64 = Console_6
control alt keycode 64 = Console_6
keycode 65 = F7 F19 Console_19 F31
alt keycode 65 = Console_7
control alt keycode 65 = Console_7
keycode 66 = F8 F20 Console_20 F32
alt keycode 66 = Console_8
control alt keycode 66 = Console_8
keycode 67 = F9 F21 Console_21 F33
alt keycode 67 = Console_9
control alt keycode 67 = Console_9
keycode 68 = F10 F22 Console_22 F34
alt keycode 68 = Console_10
control alt keycode 68 = Console_10
keycode 69 = Num_Lock
keycode 70 = Scroll_Lock Show_Memory Show_Registers Show_State
alt keycode 70 = Show_Registers
keycode 71 = KP_7
alt keycode 71 = Ascii_7
keycode 72 = KP_8
alt keycode 72 = Ascii_8
keycode 73 = KP_9
alt keycode 73 = Ascii_9
keycode 74 = KP_Subtract
keycode 75 = KP_4
alt keycode 75 = Ascii_4
keycode 76 = KP_5
alt keycode 76 = Ascii_5
keycode 77 = KP_6
alt keycode 77 = Ascii_6
keycode 78 = KP_Add
keycode 79 = KP_1
alt keycode 79 = Ascii_1
keycode 80 = KP_2
alt keycode 80 = Ascii_2
keycode 81 = KP_3
alt keycode 81 = Ascii_3
keycode 82 = KP_0
alt keycode 82 = Ascii_0
keycode 83 = KP_Period
control alt keycode 83 = Boot
keycode 84 = Last_Console
keycode 85 =
keycode 86 = less greater bar
alt keycode 86 = Meta_less
shift alt keycode 86 = Meta_greater
keycode 87 = F11 F23 Console_23 F35
alt keycode 87 = Console_11
control alt keycode 87 = Console_11
keycode 88 = F12 F24 Console_24 F36
alt keycode 88 = Console_12
control alt keycode 88 = Console_12
keycode 89 =
keycode 90 =
keycode 91 =
keycode 92 =
keycode 93 =
keycode 94 =
keycode 95 =
keycode 96 = KP_Enter
__keycode 97 = Control__
keycode 98 = KP_Divide
keycode 99 = Compose
control keycode 99 = Control_backslash
alt keycode 99 = Control_backslash
control alt keycode 99 = Meta_Control_backslash
__keycode 100 = Alt__
keycode 101 = Break
keycode 102 = Find
keycode 103 = Up
alt keycode 103 = KeyboardSignal
keycode 104 = Prior
shift keycode 104 = Scroll_Backward
keycode 105 = Left
alt keycode 105 = Decr_Console
keycode 106 = Right
alt keycode 106 = Incr_Console
keycode 107 = Select
keycode 108 = Down
keycode 109 = Next
shift keycode 109 = Scroll_Forward
keycode 110 = Insert
keycode 111 = Remove
control alt keycode 111 = Boot
keycode 112 = Macro
altgr control keycode 112 = VoidSymbol
shift alt keycode 112 = VoidSymbol
keycode 113 = F13
altgr control keycode 113 = VoidSymbol
shift alt keycode 113 = VoidSymbol
keycode 114 = F14
altgr control keycode 114 = VoidSymbol
shift alt keycode 114 = VoidSymbol
keycode 115 = Help
altgr control keycode 115 = VoidSymbol
shift alt keycode 115 = VoidSymbol
keycode 116 = Do
altgr control keycode 116 = VoidSymbol
shift alt keycode 116 = VoidSymbol
keycode 117 = F17
altgr control keycode 117 = VoidSymbol
shift alt keycode 117 = VoidSymbol
keycode 118 = KP_MinPlus
altgr control keycode 118 = VoidSymbol
shift alt keycode 118 = VoidSymbol
keycode 119 = Pause
keycode 120 =
keycode 121 =
keycode 122 =
keycode 123 =
keycode 124 =
keycode 125 =
keycode 126 =
keycode 127 =
keycode 128 = nul
altgr control keycode 128 = VoidSymbol
shift alt keycode 128 = VoidSymbol
keycode 129 = nul
altgr control keycode 129 = VoidSymbol
shift alt keycode 129 = VoidSymbol
keycode 130 = nul
altgr control keycode 130 = VoidSymbol
shift alt keycode 130 = VoidSymbol
keycode 143 = VoidSymbol
keycode 144 = nul
string F1 = "\033[[A"
string F2 = "\033[[B"
string F3 = "\033[[C"
string F4 = "\033[[D"
string F5 = "\033[[E"
string F6 = "\033[17~"
string F7 = "\033[18~"
string F8 = "\033[19~"
string F9 = "\033[20~"
string F10 = "\033[21~"
string F11 = "\033[23~"
string F12 = "\033[24~"
string F13 = "\033[25~"
string F14 = "\033[26~"
string F15 = "\033[28~"
string F16 = "\033[29~"
string F17 = "\033[31~"
string F18 = "\033[32~"
string F19 = "\033[33~"
string F20 = "\033[34~"
string Find = "\033[1~"
string Insert = "\033[2~"
string Remove = "\033[3~"
string Select = "\033[4~"
string Prior = "\033[5~"
string Next = "\033[6~"
string Macro = "\033[M"
string Pause = "\033[P"
compose '`' 'A' to U+00c0 //注音字符
compose '`' 'a' to U+00e0
compose '\'' 'A' to U+00c1
compose '\'' 'a' to U+00e1
compose '^' 'A' to U+00c2
compose '^' 'a' to U+00e2
compose '~' 'A' to U+00c3
compose '~' 'a' to U+00e3
compose '"' 'A' to U+00c4
compose '"' 'a' to U+00e4
compose '-' 'a' to U+00aa
compose '-' 'A' to U+00aa
compose 'O' 'A' to U+00c5
compose 'o' 'a' to U+00e5
compose '0' 'A' to U+00c5
compose '0' 'a' to U+00e5
compose 'A' 'A' to U+00c5
compose 'a' 'a' to U+00e5
compose '°' 'A' to U+00c5
compose '°' 'a' to U+00e5
compose 'A' 'E' to U+00c6
compose 'a' 'e' to U+00e6
compose ',' 'C' to U+00c7
compose ',' 'c' to U+00e7
compose '^' 'C' to U+00c7
compose '^' 'c' to U+00e7
compose '`' 'E' to U+00c8
compose '`' 'e' to U+00e8
compose '\'' 'E' to U+00c9
compose '\'' 'e' to U+00e9
compose '^' 'E' to U+00ca
compose '^' 'e' to U+00ea
compose '"' 'E' to U+00cb
compose '"' 'e' to U+00eb
compose '`' 'I' to U+00cc
compose '`' 'i' to U+00ec
compose '\'' 'I' to U+00cd
compose '\'' 'i' to U+00ed
compose '^' 'I' to U+00ce
compose '^' 'i' to U+00ee
compose '"' 'I' to U+00cf
compose '"' 'i' to U+00ef
compose '-' 'D' to U+00d0
compose '-' 'd' to U+00f0
compose '^' 'D' to U+00d0
compose '^' 'd' to U+00f0
compose '~' 'N' to U+00d1
compose '~' 'n' to U+00f1
compose '^' 'N' to U+00d1
compose '^' 'n' to U+00f1
compose '`' 'O' to U+00d2
compose '`' 'o' to U+00f2
compose '\'' 'O' to U+00d3
compose '\'' 'o' to U+00f3
compose '^' 'O' to U+00d4
compose '^' 'o' to U+00f4
compose '~' 'O' to U+00d5
compose '~' 'o' to U+00f5
compose '"' 'O' to U+00d6
compose '"' 'o' to U+00f6
compose '/' 'O' to U+00d8
compose '/' 'o' to U+00f8
compose '-' 'o' to U+00ba
compose '-' 'O' to U+00ba
compose '`' 'U' to U+00d9
compose '`' 'u' to U+00f9
compose '\'' 'U' to U+00da
compose '\'' 'u' to U+00fa
compose '^' 'U' to U+00db
compose '^' 'u' to U+00fb
compose '"' 'U' to U+00dc
compose '"' 'u' to U+00fc
compose '\'' 'Y' to U+00dd
compose '\'' 'y' to U+00fd
compose 'T' 'H' to U+00de
compose 't' 'h' to U+00fe
compose 's' 's' to U+00df
compose '"' 'y' to U+00ff
compose 's' 'z' to U+00df
compose 'n' 'n' to U+00f1
compose 'n' 'h' to U+00f1
compose 'N' 'Y' to U+00d1
compose 'N' 'N' to U+00d1
compose 'N' 'H' to U+00d1
compose 'N' 'y' to U+00d1
compose 'N' 'n' to U+00d1
compose 'N' 'h' to U+00d1
compose '-' 'L' to U+00a3
compose '<' '<' to U+00ab
compose '>' '>' to U+00bb
compose '?' '?' to U+00bf
compose '^' '?' to U+00bf
compose '!' '!' to U+00a1
compose '^' '!' to U+00a1
compose '^' '1' to U+00b9
compose '^' '2' to U+00b2
compose '^' '3' to U+00b3
compose '+' '-' to U+00b1
compose 'c' '=' to U+00a2
compose 'c' '/' to U+00a2
compose '/' 'c' to U+00a2
compose '-' 'c' to U+00a2
compose '-' 'C' to U+00a2
compose '|' 'c' to U+00a2
compose '|' 'C' to U+00a2
compose 'L' '=' to U+00a3
compose '-' 'L' to U+00a3
compose '-' 'l' to U+00a3
compose '^' '*' to U+00d7
compose '^' 'x' to U+00d7
compose 'x' 'x' to U+00d7
compose '^' '.' to U+00b7
compose '.' '.' to U+00b7
compose '^' '/' to U+00f7
compose '^' ':' to U+00f7
compose '-' ':' to U+00f7
compose ':' '-' to U+00f7
compose 'Y' '=' to U+00a5
compose '=' 'Y' to U+00a5
compose '-' 'Y' to U+00a5
compose '-' 'l' to U+00a5
compose '(' 'c' to U+00a9
compose '"' 'c' to U+00a9
compose 'O' 'C' to U+00a9
compose '(' 'C' to U+00a9
compose 'C' ')' to U+00a9
compose '-' 'a' to U+00aa
compose '-' 'A' to U+00aa
compose '-' 'o' to U+00ba
compose '-' 'O' to U+00ba
compose '(' 'r' to U+00ae
compose '"' 'r' to U+00ae
compose 'O' 'R' to U+00ae
compose '(' 'R' to U+00ae
compose 'R' ')' to U+00ae
compose 'm' 'u' to U+00b5
compose 'P' 'P' to U+00b6
compose '1' '4' to U+00bc
compose '1' '2' to U+00bd
compose '3' '4' to U+00be
compose 'e' '=' to U+00a4
compose '-' 'e' to U+00a4
compose '-' 'E' to U+00a4
compose '=' 'E' to U+00a4
compose 'v' 'S' to U+00a6
compose '^' 'S' to U+00a6
compose 'v' 's' to U+00a8
compose '^' 's' to U+00a8
compose 'v' 'Z' to U+00b4
compose '^' 'Z' to U+00b4
compose 'v' 'z' to U+00b8
compose '^' 'z' to U+00b8
compose 'O' 'E' to U+00bc
compose 'O' 'e' to U+00bc
compose 'o' 'e' to U+00bd
compose '"' 'Y' to U+00be
compose 'i' 'j' to U+00ff
compose 'I' 'J' to U+00be

View File

@@ -0,0 +1,878 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2012-11-19T16:23:23+08:00
====== dumpkeys -l ======
Created Monday 19 November 2012
$ dumpkeys -l __//打印loadkeys可以识别的symbols及其value,它们可以用在personal.map文件中。__
keycode range supported by kernel: 1 - 255 //kernel的终端驱动,支持一个key绑定255个keyboard actions。
max number of actions bindable to a key: 256
number of keymaps in actual use: 9 //实际上将一个key绑定9个actions,具体可以参考/usr/share/kbd/keymaps/i386/qwerty/us.map.gz
of which 2 dynamically allocated
ranges of action codes supported by kernel:
number of function keys supported by kernel: 256
max nr of compose definitions: 256
nr of compose definitions in actual use: 158
Symbols recognized by dumpkeys:
(numeric value, symbol) //number value只是序号,而非keycode
0x0000 nul
0x0001 Control_a
0x0002 Control_b
0x0003 Control_c
0x0004 Control_d
0x0005 Control_e
0x0006 Control_f
0x0007 Control_g
0x0008 BackSpace
0x0009 Tab
0x000a Linefeed
0x000b Control_k
0x000c Control_l
0x000d Control_m
0x000e Control_n
0x000f Control_o
0x0010 Control_p
0x0011 Control_q
0x0012 Control_r
0x0013 Control_s
0x0014 Control_t
0x0015 Control_u
0x0016 Control_v
0x0017 Control_w
0x0018 Control_x
0x0019 Control_y
0x001a Control_z
0x001b Escape
0x001c Control_backslash
0x001d Control_bracketright
0x001e Control_asciicircum
0x001f Control_underscore
0x0020 space
0x0021 exclam
0x0022 quotedbl
0x0023 numbersign
0x0024 dollar
0x0025 percent
0x0026 ampersand
0x0027 apostrophe
0x0028 parenleft
0x0029 parenright
0x002a asterisk
0x002b plus
0x002c comma
0x002d minus
0x002e period
0x002f slash
0x0030 zero
0x0031 **one**
0x0032 two
0x0033 three
0x0034 four
0x0035 five
0x0036 six
0x0037 seven
0x0038 eight
0x0039 nine
0x003a colon
0x003b semicolon
0x003c less
0x003d equal
0x003e greater
0x003f question
0x0040 at
0x0041 A
0x0042 B
0x0043 C
0x0044 D
0x0045 E
0x0046 F
0x0047 G
0x0048 H
0x0049 I
0x004a J
0x004b K
0x004c L
0x004d M
0x004e N
0x004f O
0x0050 P
0x0051 Q
0x0052 R
0x0053 S
0x0054 T
0x0055 U
0x0056 V
0x0057 W
0x0058 X
0x0059 Y
0x005a Z
0x005b bracketleft
0x005c backslash
0x005d bracketright
0x005e asciicircum
0x005f underscore
0x0060 grave
0x0061 a
0x0062 b
0x0063 c
0x0064 d
0x0065 e
0x0066 f
0x0067 g
0x0068 h
0x0069 i
0x006a j
0x006b k
0x006c l
0x006d m
0x006e n
0x006f o
0x0070 p
0x0071 q
0x0072 r
0x0073 s
0x0074 t
0x0075 u
0x0076 v
0x0077 w
0x0078 x
0x0079 y
0x007a z
0x007b braceleft
0x007c bar
0x007d braceright
0x007e asciitilde
0x007f Delete
0x00a0 nobreakspace
0x00a1 exclamdown
0x00a2 cent
0x00a3 sterling
0x00a4 currency
0x00a5 yen
0x00a6 brokenbar
0x00a7 section
0x00a8 diaeresis
0x00a9 copyright
0x00aa ordfeminine
0x00ab guillemotleft
0x00ac notsign
0x00ad hyphen
0x00ae registered
0x00af macron
0x00b0 degree
0x00b1 plusminus
0x00b2 twosuperior
0x00b3 threesuperior
0x00b4 acute
0x00b5 mu
0x00b6 paragraph
0x00b7 periodcentered
0x00b8 cedilla
0x00b9 onesuperior
0x00ba masculine
0x00bb guillemotright
0x00bc onequarter
0x00bd onehalf
0x00be threequarters
0x00bf questiondown
0x00c0 Agrave
0x00c1 Aacute
0x00c2 Acircumflex
0x00c3 Atilde
0x00c4 Adiaeresis
0x00c5 Aring
0x00c6 AE
0x00c7 Ccedilla
0x00c8 Egrave
0x00c9 Eacute
0x00ca Ecircumflex
0x00cb Ediaeresis
0x00cc Igrave
0x00cd Iacute
0x00ce Icircumflex
0x00cf Idiaeresis
0x00d0 ETH
0x00d1 Ntilde
0x00d2 Ograve
0x00d3 Oacute
0x00d4 Ocircumflex
0x00d5 Otilde
0x00d6 Odiaeresis
0x00d7 multiply
0x00d8 Ooblique
0x00d9 Ugrave
0x00da Uacute
0x00db Ucircumflex
0x00dc Udiaeresis
0x00dd Yacute
0x00de THORN
0x00df ssharp
0x00e0 agrave
0x00e1 aacute
0x00e2 acircumflex
0x00e3 atilde
0x00e4 adiaeresis
0x00e5 aring
0x00e6 ae
0x00e7 ccedilla
0x00e8 egrave
0x00e9 eacute
0x00ea ecircumflex
0x00eb ediaeresis
0x00ec igrave
0x00ed iacute
0x00ee icircumflex
0x00ef idiaeresis
0x00f0 eth
0x00f1 ntilde
0x00f2 ograve
0x00f3 oacute
0x00f4 ocircumflex
0x00f5 otilde
0x00f6 odiaeresis
0x00f7 division
0x00f8 oslash
0x00f9 ugrave
0x00fa uacute
0x00fb ucircumflex
0x00fc udiaeresis
0x00fd yacute
0x00fe thorn
0x00ff ydiaeresis
0x0100 F1
0x0101 F2
0x0102 F3
0x0103 F4
0x0104 F5
0x0105 F6
0x0106 F7
0x0107 F8
0x0108 F9
0x0109 F10
0x010a F11
0x010b F12
0x010c F13
0x010d F14
0x010e F15
0x010f F16
0x0110 F17
0x0111 F18
0x0112 F19
0x0113 F20
0x0114 Find
0x0115 Insert
0x0116 Remove
0x0117 Select
0x0118 Prior
0x0119 Next
0x011a Macro
0x011b Help
0x011c Do
0x011d Pause
0x011e F21
0x011f F22
0x0120 F23
0x0121 F24
0x0122 F25
0x0123 F26
0x0124 F27
0x0125 F28
0x0126 F29
0x0127 F30
0x0128 F31
0x0129 F32
0x012a F33
0x012b F34
0x012c F35
0x012d F36
0x012e F37
0x012f F38
0x0130 F39
0x0131 F40
0x0132 F41
0x0133 F42
0x0134 F43
0x0135 F44
0x0136 F45
0x0137 F46
0x0138 F47
0x0139 F48
0x013a F49
0x013b F50
0x013c F51
0x013d F52
0x013e F53
0x013f F54
0x0140 F55
0x0141 F56
0x0142 F57
0x0143 F58
0x0144 F59
0x0145 F60
0x0146 F61
0x0147 F62
0x0148 F63
0x0149 F64
0x014a F65
0x014b F66
0x014c F67
0x014d F68
0x014e F69
0x014f F70
0x0150 F71
0x0151 F72
0x0152 F73
0x0153 F74
0x0154 F75
0x0155 F76
0x0156 F77
0x0157 F78
0x0158 F79
0x0159 F80
0x015a F81
0x015b F82
0x015c F83
0x015d F84
0x015e F85
0x015f F86
0x0160 F87
0x0161 F88
0x0162 F89
0x0163 F90
0x0164 F91
0x0165 F92
0x0166 F93
0x0167 F94
0x0168 F95
0x0169 F96
0x016a F97
0x016b F98
0x016c F99
0x016d F100
0x016e F101
0x016f F102
0x0170 F103
0x0171 F104
0x0172 F105
0x0173 F106
0x0174 F107
0x0175 F108
0x0176 F109
0x0177 F110
0x0178 F111
0x0179 F112
0x017a F113
0x017b F114
0x017c F115
0x017d F116
0x017e F117
0x017f F118
0x0180 F119
0x0181 F120
0x0182 F121
0x0183 F122
0x0184 F123
0x0185 F124
0x0186 F125
0x0187 F126
0x0188 F127
0x0189 F128
0x018a F129
0x018b F130
0x018c F131
0x018d F132
0x018e F133
0x018f F134
0x0190 F135
0x0191 F136
0x0192 F137
0x0193 F138
0x0194 F139
0x0195 F140
0x0196 F141
0x0197 F142
0x0198 F143
0x0199 F144
0x019a F145
0x019b F146
0x019c F147
0x019d F148
0x019e F149
0x019f F150
0x01a0 F151
0x01a1 F152
0x01a2 F153
0x01a3 F154
0x01a4 F155
0x01a5 F156
0x01a6 F157
0x01a7 F158
0x01a8 F159
0x01a9 F160
0x01aa F161
0x01ab F162
0x01ac F163
0x01ad F164
0x01ae F165
0x01af F166
0x01b0 F167
0x01b1 F168
0x01b2 F169
0x01b3 F170
0x01b4 F171
0x01b5 F172
0x01b6 F173
0x01b7 F174
0x01b8 F175
0x01b9 F176
0x01ba F177
0x01bb F178
0x01bc F179
0x01bd F180
0x01be F181
0x01bf F182
0x01c0 F183
0x01c1 F184
0x01c2 F185
0x01c3 F186
0x01c4 F187
0x01c5 F188
0x01c6 F189
0x01c7 F190
0x01c8 F191
0x01c9 F192
0x01ca F193
0x01cb F194
0x01cc F195
0x01cd F196
0x01ce F197
0x01cf F198
0x01d0 F199
0x01d1 F200
0x01d2 F201
0x01d3 F202
0x01d4 F203
0x01d5 F204
0x01d6 F205
0x01d7 F206
0x01d8 F207
0x01d9 F208
0x01da F209
0x01db F210
0x01dc F211
0x01dd F212
0x01de F213
0x01df F214
0x01e0 F215
0x01e1 F216
0x01e2 F217
0x01e3 F218
0x01e4 F219
0x01e5 F220
0x01e6 F221
0x01e7 F222
0x01e8 F223
0x01e9 F224
0x01ea F225
0x01eb F226
0x01ec F227
0x01ed F228
0x01ee F229
0x01ef F230
0x01f0 F231
0x01f1 F232
0x01f2 F233
0x01f3 F234
0x01f4 F235
0x01f5 F236
0x01f6 F237
0x01f7 F238
0x01f8 F239
0x01f9 F240
0x01fa F241
0x01fb F242
0x01fc F243
0x01fd F244
0x01fe F245
0x01ff F246
0x0200 VoidSymbol
**0x0201 Return**
0x0202 Show_Registers
0x0203 Show_Memory
0x0204 Show_State
**0x0205 Break**
0x0206 Last_Console
__0x0207 Caps_Lock__
0x0208 Num_Lock
0x0209 Scroll_Lock
0x020a Scroll_Forward
0x020b Scroll_Backward
**0x020c Boot //没有使用。**
0x020d Caps_On
0x020e Compose
0x020f SAK
0x0210 Decr_Console
0x0211 Incr_Console
0x0212 KeyboardSignal
0x0213 Bare_Num_Lock
0x0300 KP_0
0x0301 KP_1
0x0302 KP_2
0x0303 KP_3
0x0304 KP_4
0x0305 KP_5
0x0306 KP_6
0x0307 KP_7
0x0308 KP_8
0x0309 KP_9
0x030a KP_Add
0x030b KP_Subtract
0x030c KP_Multiply
0x030d KP_Divide
0x030e KP_Enter
0x030f KP_Comma
0x0310 KP_Period
0x0311 KP_MinPlus
0x0400 dead_grave
0x0401 dead_acute
0x0402 dead_circumflex
0x0403 dead_tilde
0x0404 dead_diaeresis
0x0405 dead_cedilla
0x0500 Console_1
0x0501 Console_2
0x0502 Console_3
0x0503 Console_4
0x0504 Console_5
0x0505 Console_6
0x0506 Console_7
0x0507 Console_8
0x0508 Console_9
0x0509 Console_10
0x050a Console_11
0x050b Console_12
0x050c Console_13
0x050d Console_14
0x050e Console_15
0x050f Console_16
0x0510 Console_17
0x0511 Console_18
0x0512 Console_19
0x0513 Console_20
0x0514 Console_21
0x0515 Console_22
0x0516 Console_23
0x0517 Console_24
0x0518 Console_25
0x0519 Console_26
0x051a Console_27
0x051b Console_28
0x051c Console_29
0x051d Console_30
0x051e Console_31
0x051f Console_32
0x0520 Console_33
0x0521 Console_34
0x0522 Console_35
0x0523 Console_36
0x0524 Console_37
0x0525 Console_38
0x0526 Console_39
0x0527 Console_40
0x0528 Console_41
0x0529 Console_42
0x052a Console_43
0x052b Console_44
0x052c Console_45
0x052d Console_46
0x052e Console_47
0x052f Console_48
0x0530 Console_49
0x0531 Console_50
0x0532 Console_51
0x0533 Console_52
0x0534 Console_53
0x0535 Console_54
0x0536 Console_55
0x0537 Console_56
0x0538 Console_57
0x0539 Console_58
0x053a Console_59
0x053b Console_60
0x053c Console_61
0x053d Console_62
0x053e Console_63
0x0600 Down
0x0601 Left
0x0602 Right
0x0603 Up
__0x0700 Shift //在后面可以看到ShiftL, ShiftR是Shift的同义词。__
__0x0701 AltGr__
__0x0702 Control__
__0x0703 Alt__
**0x0704 ShiftL**
**0x0705 ShiftR**
**0x0706 CtrlL**
**0x0707 CtrlR**
0x0708 CapsShift
0x0800 Meta_nul
0x0801 Meta_Control_a
0x0802 Meta_Control_b
0x0803 Meta_Control_c
0x0804 Meta_Control_d
0x0805 Meta_Control_e
0x0806 Meta_Control_f
0x0807 Meta_Control_g
0x0808 Meta_BackSpace
0x0809 Meta_Tab
0x080a Meta_Linefeed
0x080b Meta_Control_k
0x080c Meta_Control_l
0x080d Meta_Control_m
0x080e Meta_Control_n
0x080f Meta_Control_o
0x0810 Meta_Control_p
0x0811 Meta_Control_q
0x0812 Meta_Control_r
0x0813 Meta_Control_s
0x0814 Meta_Control_t
0x0815 Meta_Control_u
0x0816 Meta_Control_v
0x0817 Meta_Control_w
0x0818 Meta_Control_x
0x0819 Meta_Control_y
0x081a Meta_Control_z
0x081b Meta_Escape
0x081c Meta_Control_backslash
0x081d Meta_Control_bracketright
0x081e Meta_Control_asciicircum
0x081f Meta_Control_underscore
0x0820 Meta_space
0x0821 Meta_exclam
0x0822 Meta_quotedbl
0x0823 Meta_numbersign
0x0824 Meta_dollar
0x0825 Meta_percent
0x0826 Meta_ampersand
0x0827 Meta_apostrophe
0x0828 Meta_parenleft
0x0829 Meta_parenright
0x082a Meta_asterisk
0x082b Meta_plus
0x082c Meta_comma
0x082d Meta_minus
0x082e Meta_period
0x082f Meta_slash
0x0830 Meta_zero
0x0831 Meta_one
0x0832 Meta_two
0x0833 Meta_three
0x0834 Meta_four
0x0835 Meta_five
0x0836 Meta_six
0x0837 Meta_seven
0x0838 Meta_eight
0x0839 Meta_nine
0x083a Meta_colon
0x083b Meta_semicolon
0x083c Meta_less
0x083d Meta_equal
0x083e Meta_greater
0x083f Meta_question
0x0840 Meta_at
0x0841 Meta_A
0x0842 Meta_B
0x0843 Meta_C
0x0844 Meta_D
0x0845 Meta_E
0x0846 Meta_F
0x0847 Meta_G
0x0848 Meta_H
0x0849 Meta_I
0x084a Meta_J
0x084b Meta_K
0x084c Meta_L
0x084d Meta_M
0x084e Meta_N
0x084f Meta_O
0x0850 Meta_P
0x0851 Meta_Q
0x0852 Meta_R
0x0853 Meta_S
0x0854 Meta_T
0x0855 Meta_U
0x0856 Meta_V
0x0857 Meta_W
0x0858 Meta_X
0x0859 Meta_Y
0x085a Meta_Z
0x085b Meta_bracketleft
0x085c Meta_backslash
0x085d Meta_bracketright
0x085e Meta_asciicircum
0x085f Meta_underscore
0x0860 Meta_grave
0x0861 Meta_a
0x0862 Meta_b
0x0863 Meta_c
0x0864 Meta_d
0x0865 Meta_e
0x0866 Meta_f
0x0867 Meta_g
0x0868 Meta_h
0x0869 Meta_i
0x086a Meta_j
0x086b Meta_k
0x086c Meta_l
0x086d Meta_m
0x086e Meta_n
0x086f Meta_o
0x0870 Meta_p
0x0871 Meta_q
0x0872 Meta_r
0x0873 Meta_s
0x0874 Meta_t
0x0875 Meta_u
0x0876 Meta_v
0x0877 Meta_w
0x0878 Meta_x
0x0879 Meta_y
0x087a Meta_z
0x087b Meta_braceleft
0x087c Meta_bar
0x087d Meta_braceright
0x087e Meta_asciitilde
0x087f Meta_Delete
0x0900 Ascii_0
0x0901 Ascii_1
0x0902 Ascii_2
0x0903 Ascii_3
0x0904 Ascii_4
0x0905 Ascii_5
0x0906 Ascii_6
0x0907 Ascii_7
0x0908 Ascii_8
0x0909 Ascii_9
0x090a Hex_0
0x090b Hex_1
0x090c Hex_2
0x090d Hex_3
0x090e Hex_4
0x090f Hex_5
0x0910 Hex_6
0x0911 Hex_7
0x0912 Hex_8
0x0913 Hex_9
0x0914 Hex_A
0x0915 Hex_B
0x0916 Hex_C
0x0917 Hex_D
0x0918 Hex_E
0x0919 Hex_F
0x0a00 Shift_Lock __//_Lock表示,Caps Lock键先被按下。__
0x0a01 AltGr_Lock
0x0a02 Control_Lock
0x0a03 Alt_Lock
0x0a04 ShiftL_Lock
0x0a05 ShiftR_Lock
0x0a06 CtrlL_Lock
0x0a07 CtrlR_Lock
0x0a08 CapsShift_Lock
0x0c00 SShift
0x0c01 SAltGr
0x0c02 SControl
0x0c03 SAlt
0x0c04 SShiftL
0x0c05 SShiftR
0x0c06 SCtrlL
0x0c07 SCtrlR
0x0c08 SCapsShift
0x0e00 Brl_blank
0x0e01 Brl_dot1
0x0e02 Brl_dot2
0x0e03 Brl_dot3
0x0e04 Brl_dot4
0x0e05 Brl_dot5
0x0e06 Brl_dot6
0x0e07 Brl_dot7
0x0e08 Brl_dot8
0x0e09 Brl_dot9
0x0e0a Brl_dot10
The following synonyms (同义)are recognized:
Control_h for BackSpace
Control_i for Tab
Control_j for Linefeed
Home for Find
End for Select
PageUp for Prior
PageDown for Next
multiplication for multiply
pound for sterling
pilcrow for paragraph
Oslash for Ooblique
**Shift_L for ShiftL**
**Shift_R for ShiftR**
**Control_L for CtrlL**
**Control_R for CtrlR**
**AltL for Alt**
**AltR for AltGr**
**Alt_L for Alt**
**Alt_R for AltGr**
**AltGr_L for Alt**
**AltGr_R for AltGr**
AltLLock for Alt_Lock
AltRLock for AltGr_Lock
SCtrl for SControl
Spawn_Console for KeyboardSignal
Uncaps_Shift for CapsShift
lambda for lamda
Lambda for Lamda
xi for ksi
Xi for Ksi
chi for khi
Chi for Khi
tilde for asciitilde
circumflex for asciicircum
dead_ogonek for dead_cedilla
dead_caron for dead_circumflex
dead_breve for dead_tilde
dead_doubleacute for dead_tilde
Idotabove for Iabovedot
dotlessi for idotless
no-break_space for nobreakspace
paragraph_sign for section
soft_hyphen for hyphen
bielorussian_cyrillic_capital_letter_i for ukrainian_cyrillic_capital_letter_i
cyrillic_capital_letter_kha for cyrillic_capital_letter_ha
cyrillic_capital_letter_ge for cyrillic_capital_letter_ghe
cyrillic_capital_letter_ia for cyrillic_capital_letter_ya
cyrillic_capital_letter_iu for cyrillic_capital_letter_yu
cyrillic_capital_letter_yeri for cyrillic_capital_letter_yeru
cyrillic_capital_letter_reversed_e for cyrillic_capital_letter_e
cyrillic_capital_letter_ii for cyrillic_capital_letter_i
cyrillic_capital_letter_short_ii for cyrillic_capital_letter_short_i
bielorussian_cyrillic_small_letter_i for ukrainian_cyrillic_small_letter_i
cyrillic_small_letter_kha for cyrillic_small_letter_ha
cyrillic_small_letter_ge for cyrillic_small_letter_ghe
cyrillic_small_letter_ia for cyrillic_small_letter_ya
cyrillic_small_letter_iu for cyrillic_small_letter_yu
cyrillic_small_letter_yeri for cyrillic_small_letter_yeru
cyrillic_small_letter_reversed_e for cyrillic_small_letter_e
cyrillic_small_letter_ii for cyrillic_small_letter_i
cyrillic_small_letter_short_ii for cyrillic_small_letter_short_i
rightanglequote for guillemotright
Recognized modifier names and their column numbers:
shift 1
altgr 2
control 4
alt 8
shiftl 16
shiftr 32
ctrll 64
ctrlr 128
capsshift 256

View File

@@ -0,0 +1,68 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2012-11-19T17:08:03+08:00
====== personal.map ======
Created Monday 19 November 2012
本文件是在us.map的基础上修改的,功能是将Ctrl和Alt相互调换,同时不区分左右Alt。
可以先用**showkey命令**查看键盘上各按键对应的keycode,然后修改该文件。
注意:keymaps只适合于虚拟终端环境,对于X app,可以使用xmodmap命令。
# us.map
keymaps 0-2,4-6,8-9,12
**alt_is_meta**
include "qwerty-layout"
**include "linux-with-two-alt-keys" //为emacs使用,目的是不区分左右Alt。 from:archlinux wiki:KEYMAPS**
include "compose.latin1"
include "euro1.map"
strings as usual
keycode 1 = Escape
keycode 2 = one exclam
keycode 3 = two at at nul nul
keycode 4 = three numbersign
control keycode 4 = Escape
keycode 5 = four dollar dollar Control_backslash
keycode 6 = five percent
control keycode 6 = Control_bracketright
keycode 7 = six asciicircum
control keycode 7 = Control_asciicircum
keycode 8 = seven ampersand braceleft Control_underscore
keycode 9 = eight asterisk bracketleft Delete
keycode 10 = nine parenleft bracketright
keycode 11 = zero parenright braceright
keycode 12 = minus underscore backslash Control_underscore Control_underscore
keycode 13 = equal plus
keycode 14 = Delete
keycode 15 = Tab
shift keycode 15 = Meta_Tab
keycode 26 = bracketleft braceleft
control keycode 26 = Escape
keycode 27 = bracketright braceright asciitilde Control_bracketright
keycode 28 = Return
alt keycode 28 = Meta_Control_m
__#keycode 29 = Control //29对应的的是空格左边的Control按键,现在将其与绑定到Alt modifier。__
__keycode 29 = Alt__
keycode 39 = semicolon colon
keycode 40 = apostrophe quotedbl
control keycode 40 = Control_g
keycode 41 = grave asciitilde
control keycode 41 = nul
keycode 42 = Shift
keycode 43 = backslash bar
control keycode 43 = Control_backslash
keycode 51 = comma less
keycode 52 = period greater
keycode 53 = slash question
control keycode 53 = Control_underscore
control shift keycode 53 = Delete
keycode 54 = Shift
__#keycode 56 = Alt //56对应的是空格左边的Alt按键,现在将其绑定到Control modifier。__
__keycode 56 = Control__
keycode 57 = space
control keycode 57 = nul
keycode 58 = Caps_Lock
keycode 86 = less greater bar
__keycode 97 = Control //空格右边的Control和Alt键不用修改。__
keycode 100 = Alt

View File

@@ -0,0 +1,72 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2012-11-19T19:12:45+08:00
====== wiki KEYMAPS ======
Created Monday 19 November 2012
https://wiki.archlinux.org/index.php/KEYMAP
===== KEYMAP =====
The **KEYMAP** variable is specified in the __/etc/vconsole.conf__ file. It defines what keymap the keyboard is in the virtual consoles. Keytable files are provided by the **kbd** package.
===== Keyboard layouts =====
This is the list of known keymap settings to work for the corresponding **keyboard layouts**. Most keymaps can be found in the **/usr/share/kbd/keymaps/i386**/layout (__layout=qwerty, azerty, dvorak, etc__.) directory.
Less common but nonetheless useful keymaps for Arch Linux are found in the /usr/share/kbd/keymaps/architecture (architecture=mac, sun, etc.) directory.
Note: In an X session, you can use setxkbmap to instantly apply keyboard layout: setxkbmap -layout dvorak
Note: If these keymaps do not work for you, make sure the keymap file exists in /usr/share/kbd/keymaps/ using find: find /usr/share/kbd/keymaps/ -name "*[your desired keymap]*"
**Keyboard Keymap setting**
Belgian KEYMAP=be-latin1
Brazilian Portuguese KEYMAP=br-abnt2
Canadian-French KEYMAP=cf
Canadian Multilingual (in AUR) KEYMAP=ca_multi
Colemak (US) KEYMAP=colemak
Croatian KEYMAP=croat
Czech KEYMAP=cz-lat2
Dvorak KEYMAP=dvorak
French KEYMAP=fr-latin1
German KEYMAP=de-latin1
German (no dead keys) KEYMAP=de-latin1-nodeadkeys
Italian KEYMAP=it
Lithuanian (qwerty) KEYMAP=lt.baltic
Norwegian KEYMAP=no-latin1
Polish KEYMAP=pl
Portuguese KEYMAP=pt-latin9
Romanian KEYMAP=ro_win
Russian KEYMAP=ru4
Singapore KEYMAP=sg-latin1
Slovene KEYMAP=slovene
Swedish KEYMAP=sv-latin1
Swiss-French KEYMAP=fr_CH-latin1
Swiss-German KEYMAP=de_CH-latin1
Spanish KEYMAP=es
Spanish Latinoamerican KEYMAP=la-latin1
Turkish KEYMAP=tr_q-latin5
Ukrainian KEYMAP=ua
United Kingdom KEYMAP=gb or KEYMAP=uk in the installer.
===== Configuring the Console Keymap =====
1. cd to /usr/share/kbd/keymaps/i386/qwerty
2. Copy your default keymap (us.map.gz) to a new file personal.map.gz
3. gunzip the new map file
4. Edit personal.map using your favorite editor. Examples:
__Make the Right Alt key same as Left Alt key (Emacs)__
change the line include "linux-with-alt-and-altgr" to include "linux-with-two-alt-keys"
Swap CapsLock with Escape (Vim)
make keycode 1 = Caps_Lock and keycode 58 = Escape
Make CapsLock another Control key
change the line keycode 58 = Caps_Lock to keycode 58 = Control
Swap CapsLock with Left Control key
make keycode 29 = Caps_Lock and keycode 58 = Control
注意:可以使用showkey命令查看,虚拟终端环境中某个按键的keycode(对于X 环境可以使用xev命令)。
5. gzip the map file
Change the default keyboard layout file that will be used by editing /etc/vconsole.conf (you might have to create this file) and changing the line that says KEYMAP=us to KEYMAP=personal
6. Reboot to use your keymap the way nature intended (or run "__loadkeys personal__")

View File

@@ -0,0 +1,88 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2012-11-19T19:58:36+08:00
====== wiki xmodmap ======
Created Monday 19 November 2012
https://wiki.archlinux.org/index.php/Xmodmap
===== Summary =====
A general overview of modifying **keymaps and pointer** mappings with xmodmap.
===== Introduction =====
The Linux kernel generates a code each time a key is pressed on a keyboard. That code is compared to __a table of keycodes__ defining a figure that is then displayed.
This process is complicated by **Xorg**, which starts its own table of keycodes. __Each keycode can belong to a keysym__. A keysym is like a function, started by typing a key. Xmodmap allows you to edit these keycode-keysym relations.
===== Keymap table =====
Print the current keymap table **formatted into expressions**:
$ xmodmap -pke
keycode 57 = n N
Each keymap is followed by the keysyms it is mapped to. The above example indicates that the keycode 57 is mapped to the lowercase n, while the uppercase N is mapped to keycode 57 and Shift.
**xmodmap文件的语法格式与keymaps相似,具体格式可以参考:**[[keymaps]] 。**内核可以识别的所有keysyms可以在虚拟终端中用dumpkeys -l命令查看。**
Each keysym column in the table corresponds to a particular key combination:
1. Key
2. Shift+Key
3. mode_switch+Key
4. mode_switch+Shift+Key
5. AltGr+Key
6. AltGr+Shift+Key
Not all keysyms have to be set, but if you want to assign a latter keysym without assigning earlier ones set them to **NoSymbol**.
You can check which keymap corresponds to a key on your keyboard with __xev__.
Tip: There are predefined descriptive keycodes that make mapping additional keys easier (e.g. XF86AudioMute, XF86Mail). Those keycodes can be found in: /usr/include/X11/XF86keysym.h
===== Custom table =====
You can create your own map and store it in your home directory (i.e. ~/.Xmodmap). Print the current keymap table into a configuration file:
__xmodmap -pke > ~/.Xmodmap__
Make the desired changes to ~/.Xmodmap and then test the new configuration with:
xmodmap ~/.Xmodmap
To activate your custom table when starting Xorg add the following:
~/.xinitrc
if [ -f $HOME/.Xmodmap ]; then
/usr/bin/xmodmap $HOME/.Xmodmap
fi
Alternatively, edit the global startup script /etc/X11/xinit/xinitrc.
===== Test changes =====
You can also make temporary changes for the current session. For example:
xmodmap -e "keycode 46 = l L l L lstroke Lstroke lstroke"
xmodmap -e "keysym a = e E"
===== Special keys/signals =====
You can also also edit the keys: Shift, Ctrl, Alt and Super (there always exists a left and a right one (__Alt_R=AltGr__))
At first you have to delete/clear the signals that should be edited. In the beginning of your ~/.Xmodmap:
!clear Shift
!clear Lock
clear Control
!clear Mod1
!clear Mod2
!clear Mod3
clear Mod4
!clear Mod5
keycode 8 =
...
Remember, ! is a comment so only Control and Mod4 (Standard: Super_L Super_R) get cleared.
Write the new signals at the end of ~/.Xmodmap
keycode 255 =
!add Shift = Shift_L Shift_R
!add Lock = Caps_Lock
add Control = Super_L Super_R
!add Mod1 = Alt_L Alt_R
!add Mod2 = Mode_switch
!add Mod3 =
add Mod4 = Control_L Control_R
!add Mod5 =
The Super keys have now been exchanged with the Ctrl keys.
===== Reverse Scrolling =====
The natural scrolling feature available in OS X Lion can be mimicked with xmodmap. Since the synaptics driver uses the buttons 4/5/6/7 for up/down/left/right scrolling, you simply need to swap the order of how the buttons are declared in ~/.Xmodmap.
Open ~/.Xmodmap and append the following line to the file:
pointer = 1 2 3 5 4 7 6 8 9 10 11 12
Note how the 4 and 5 have been reversed.
Then update xmodmap:
xmodmap ~/.Xmodmap
To return to regular scrolling simply reverse the order of the 4 and 5 or delete the line altogether. For more information check Peter Hutterer's post, Natural scrolling in the synaptics driver, or the Reverse scrolling direction ala Mac OS X Lion? forum thread.

View File

@@ -0,0 +1,133 @@
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2012-11-19T11:27:20+08:00
====== xmodmap ======
Created Monday 19 November 2012
http://lins05.mysmth.net/2011/04/24/67/
注意:xmodmap修改键盘布局的方法只适用于X client app,对于虚拟终端应用,需要修改keymaps文件,可以参考:[[wiki KEYMAPS]]
这是一篇介绍xmodmap工具的简单教程,适合于以下童鞋:
* Emacs用户,需要交换 CapsLock 和 left Ctrl的人,或者和我一样交换Alt_L和Control_L。
* 其他有改键需要的人。
* 喜欢瞎折腾的人。
读了这篇帖子,你会发现在linux下修改键盘布局是如此的简单(我替你们做了功课:花二十分钟通读了xmodmap的man手册)。
===== 提出问题: =====
如何交换CapsLock和左边的Ctrl键?
答:
# xmodmap -e "remove lock = Caps_Lock"
# xmodmap -e "remove control = Control_L"
# xmodmap -e "add control = Caps_Lock"
# xmodmap -e "add lock = Control_L"
后面的内容是具体的教程,前面是提供给只需要一个做法而不需要了解具体的原理的。如果你属于此类,完全可以不看后面的内容了。 不过原理很简单,而且一旦学会,改键就跟grep一个正则表达式差不多简单。
===== 分析问题: =====
看到这里的人,应该是有耐心理解下面三个概念的: keycode/keysym/modifier 这三个概念是键盘相关的、层次从低到高的三个名词。
===== keycode– =====
一般的键盘上有102或者105键,每一个键被按下时会产生一个特有类型、主板能够分辨的电信号,传输给主板,主板给不同的电信号定下不同的编号,这就是所谓的keycode。 这些电信号是在生产键盘时就定死了的,比如左边的Ctrl键产生的keycode是37。CapsLock键产生的keycode是66。 要查找某个按键的keycode,可以在term中用__`xev`__程序来查看。xev使用很简单,它运行时,你按下一个键,term中就会显示这个键的许多信息,其中就有keycode。 这些keycode是硬件决定的,你我无法改变。总之记住,一个按键产生的keycode是不可能在软件中改变的。
===== keysym– =====
操作系统按照统一的规范,给不同的keycode映射为不同的含义,这个映射后的含义的术语就叫做keysym。比如你在emacs中打字时按下一个s键。屏幕上出现一个`s`,而不是出现一个`b`,是因为:系统接收到s的keycode–我用xev查了下,keycode(s) = 39, 按照默认的标准,39对应于字母`s`,于是就这个`s`显示在屏幕上。 (当然,更严谨地、更准确地说,应该是把`s`这个字母作为输入传递给Emacs,emacs再把这个字母插入到当前的文件中的。) 这里,keycode是39,其对应的符号,术语叫keysym,即`key symbol`,就是字母`s`。 同理你按下键盘上的’b'(keycode(b) = 56),它的(默认的)keysym就是字母`b`。 系统给一个keycode分配的keysym不只一个。对于一个字母键,至少两个。第一个是单独按下这个键时对应的一,第二个是shift和这个键同时按下时的keysym。 键盘上,还有另外一类按键,它们单独按下时,一般没有任何意义,只有与其他的按照一直按下时是,才会产生一些特殊的效果,比如Ctrl、Shift、win键;它们实现的效果,称为modifier。
===== Modifier–修饰符 =====
“修饰符”的修饰二字很好解释,你按下s,是打一个字母s,你按下Ctrl+s,大部分软件里,会保存当前文件;你按下Shift+s,是打另一个字母S。总之是 “改变一个键的本来含义“。因为`modify`本来就是修改的意思。 在term里输入命令`xmodmap`,会出现以下内容
┌─[geekard @ kb310]─[16:27]─[~]─[326]
└─[$] xmodmap
xmodmap: up to 4 keys per modifier (keycodes in parentheses):
shift Shift_L (0x32) Shift_R (0x3e)
lock Caps_Lock (0x42)
control Control_L (0x40) Control_R (0x69)
mod1 Alt_L (0x25) Alt_R (0x6c) Alt_L (0xcc) Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x85) Super_R (0x86) Super_L (0xce) Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c) Mode_switch (0xcb)
左边那一列,就是系统中所有的`modifier`。 系统会把一些默认的keysym解释为modifier,比如,默认情况下,你按下Shift + s, 屏幕上出现大写的S整个过程其实是:
* 系统收到Shift键和s键的keycode
* 系统处理 keycode–>keysym 的映射: shift的keycode被映射到`SHIFT_L`这个keysym;s的keycode被映射到`s`这个keysym
* 系统发现,SHIFT_L这个keysym被定义为shfit这个modifier。
* `s`被shift这个modifier给修饰了,修饰的结果是变成了大写的S。
基本概念讲完了,那么,`xmodmap`是如何帮我们实现`改键`的呢? 可以看到,从按下一个键到最后,有两个层次的映射过程:
第一层: keycode–>keysym
第二层: keysym –> modifier
因此,我们可以通过两种方法来实现改键。
===== 目标1:把键盘上的s和a键交换位置 =====
先查询s和a对应的keycode,方法还是使用`xev'程序。例如我的输出如下:
KeyPress event serial 39 synthetic NO window 0x3200001
root 0xb7 subw 0x0 time 14363110 (97129) root:(99152)
state 0x10 keycode 39 (keysym 0x73 s) same_screen YES
XLookupString gives 1 bytes: (73) "s"
XmbLookupString gives 1 bytes: (73) "s"
XFilterEvent returns: False
......
KeyPress event serial 39 synthetic NO window 0x3200001
root 0xb7 subw 0x0 time 14364150 (97129) root:(99152)
state 0x10 keycode 38 (keysym 0x61 a) same_screen YES
XLookupString gives 1 bytes: (61) "a"
XmbLookupString gives 1 bytes: (61) "a"
XFilterEvent returns: False
===== 交换s/a的位置: =====
# xmodmap -e "keycode 39 = a"
# xmodmap -e "keycode 38 = s"
这样,就交换了 s/a 这两个键的位置了! 注意,在你执行了第一条语句之后,s立刻被重新映射到a了,那么你第二条语句中的`s`怎么打出来呢?
两个方法: i) 从别处粘贴一个过来 ii)见最后的`xmodmap执行命令的三种方式`
注意:这个方法只能交换一般的keysym,那些定义为Modifier的键,就不能简单地用这个方式交换。
因为: 当一个keysym被定义为modifier,那么,__本质上是在 keycode–>modifier之间建立起了一个映射__。因此,即使你改变了它的keycode–>keysym关系,也不起作用! 也就是说:当你要把一个键定义一个modifier时,你只能把它的keycode对应的keysym定义为modifier,从而达到目的。但这之后,即使keycode映射到别的keysym了,这个keycode仍然是一个modifier。 因此,如果要交换CapsLock和Ctrl这两个键,只需要做两件事:
* 把`Caps_Lock`这个keysym定义为`control`这个modifer
* 把`Control_L`这个keysym定义为`Caps_Lock`这个modifier (Control_L是左Ctrl键的默认keysym)
===== 目标2: 交换 Caps_Lock和 左边的Ctrl =====
先把CapsLock这个keysym映射到control这个modifier:
# xmodmap -e "remove lock = Caps_Lock"
# xmodmap -e "add control = Caps_Lock"
__因为一个keysym不能同时映射到两个modifier__,因此,我们需要先用remove把Caps_Lock这个keysym与lock这个modifier的映射关系删除(当前的modifier与keysymb的关系可以用xmodmap -pkm命令查看。)。然后,再把Caps_Lock这个keysym映射到Control这个modifier。 remove和add的的语法是:
复制代码
remove/add modifier_name = keysym_name
此时,你可以试一下,看看是否已经产生效果了?
同样,再把左边的Ctrl键映射到CapsLock:
# xmodmap -e "remove control = Control_L"
# xmodmap -e "add Caps_Lock = Control_L"
===== 目标3:交换左侧的Ctrl和Alt,同时将右侧的Alt映射到Esc(这样可以支持命令行编辑) =====
1. 先用xmodmap -pm查看当前的modifier与哪些keycode绑定(间接通过keysyms)
$ xmodmap -pm
xmodmap: up to 4 keys per modifier, (keycodes in parentheses):
shift Shift_L (0x32), Shift_R (0x3e)
lock Caps_Lock (0x42)
control Control_L (0x40), Control_R (0x69)
mod1 Alt_L (0x25), Escape (0x6c), Alt_L (0xcc), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
2. 然后编辑~/.xmodmap文件:
!swithc alt and ctl
remove Mod1 = Alt_L
remove Control = Control_L
keycode 37= Alt_L
keycode 64 = Control_L
!Right Alt maps to Esc
keycode 108 = Escape
add Control = Control_L
add Mod1 = Alt_L
xmodmap执行命令的三种方式:
1) xmodmap -e "do somthing" 是让xmodmap执行后面的一条句子。但这样一次只能执行一条。
2) 你也可以先输入 `xmodmap -`,然后回车,然后输入任意多句子,每输入一条就用回车分隔,最后用Ctrl+D结束输入。
3) 把remove xxx = yyy 这些句子都写到一个文件里。一般是~/.Xmodmap。然后用 `xmodmap ~/.Xmodmap`执行。 这样的好处是,在启动时的某个脚本里加一行命令,就不用每次重启都手动地改键了。