Apenas para adicionar alguns detalhes da resposta aceita, aqui está o que eu vejo e o que eu fiz para fazê-lo funcionar; irá adicionar mais truques e reviravoltas se eu os encontrar.
Usar sudo dumpkeys
fornecerá a saída assim:
keycode 12 = minus
shift keycode 12 = underscore
shift altgr keycode 12 = underscore
control keycode 12 = Control_underscore
shift control keycode 12 = Control_underscore
altgr control keycode 12 = Control_underscore
shift altgr control keycode 12 = Control_underscore
alt keycode 12 = Meta_minus
...
E, se você abrir os arquivos de mapa de teclado em /lib/kbd/keymaps/xkb/
, verá que em uma linha há várias colunas (às vezes muitas) como:
keycode 12 = U+002d U+005f U+002d U+005f Control_underscore Control_underscore Control_underscore ...
De acordo com a página do manual de keymaps
: ( man 5 keymaps
), temos:
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
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 definition 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. 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. 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.)
E sabemos que U+002d
é Hyphen-Minus
e U+005f
é low-line
, então agora a vemos clara: cada linha no arquivo keymap, é o código-chave e seus caracteres keys emitidos quando a própria chave, deslocar + tecla, shift + altgr + tecla, ... é pressionada, nessa ordem.
(Caso você esqueça a tabela, podemos usar dumpkeys --long-info
para mostrá-la).
Eles correspondem um ao outro: as linhas na primeira parte correspondem às colunas na segunda parte .
Melhor visualizá-lo em uma tabela:
+----------+------------------------+----------------------------+
| | | |
| col. | key to press(+ keycode)| chars to produce (keysys) |
| | | |
+----------------------------------------------------------------+
| | | |
| 0 | keycode 12 | minus |
| | | |
+----------------------------------------------------------------+
| | | |
| 1 | shift | underscore |
| | | |
+----------------------------------------------------------------+
| | | |
| 2 | altgr | underscore |
| | | |
+----------------------------------------------------------------+
| | | |
| 3(1+2) | shift + altgr | underscore |
| | | |
+----------------------------------------------------------------+
| | | |
| 4 | ctrl | ctrl + underscore |
| | | |
+----------------------------------------------------------------+
| | | |
| 5(4+1) | ctrl + shift | ctrl + underscore |
| | | |
+----------+------------------------+----------------------------+
| | | |
| 6(4+2) | ctrl + alt | ctrl + underscore |
| | | |
+----------+------------------------+----------------------------+