「コンソールでの特別なキーボードキー」の版間の差分
ナビゲーションに移動
検索に移動
(ページの作成:「Category:キーボード en:Extra keyboard keys in console {{Related articles start}} {{Related|特別なキーボードキー}} {{Related|Xorg での特別なキ...」) |
Kusanaginoturugi (トーク | 投稿記録) (リダイレクトに変更) タグ: 新規リダイレクト |
||
(他の1人の利用者による、間の2版が非表示) | |||
1行目: | 1行目: | ||
− | [[ |
+ | #REDIRECT [[Linux コンソール/キーボード設定#カスタムキーマップの作成]] |
− | [[en:Extra keyboard keys in console]] |
||
− | {{Related articles start}} |
||
− | {{Related|特別なキーボードキー}} |
||
− | {{Related|Xorg での特別なキーボードキー}} |
||
− | {{Related|スキャンコードをキーコードにマップ}} |
||
− | {{Related articles end}} |
||
− | |||
− | When using the console, you can use hotkeys to print a specific character. Moreover we can also print a sequence of characters and some escape sequences. Thus, if we print the sequence of characters constituting a command and afterwards an escape character for a new line, that command will be executed! |
||
− | |||
− | One method of doing this is editing [[KEYMAP|the keymap]]. However, the keymap is a sensitive file, and since it will be rewritten anytime the package it belongs to is updated, editing this file is discouraged. It is better to integrate the existing keymap with a personal keymap. The {{ic|loadkeys}} utility can do this. |
||
− | |||
− | == カスタムキーマップの作成 == |
||
− | |||
− | First, create a keymap file. This keymap file can be anywhere, but one method is to mimic the directory hierarchy in {{ic|/usr/local}}: |
||
− | |||
− | # mkdir -p /usr/local/share/kbd/keymaps |
||
− | # vim /usr/local/share/kbd/keymaps/personal.map |
||
− | |||
− | As a side note, it is worth noting that such a personal keymap is useful also to redefine the behaviour of keys already treated by the default keymap: when loaded with {{ic|loadkeys}}, the directives in the default keymap will be replaced when they conflict with the new directives and conserved otherwise. This way, only changes to the keymap must be specified in the personal keymap. |
||
− | |||
− | {{Tip|You can also edit an existing keymap located in the {{ic|/usr/share/kbd/keymaps/}} directory tree. Keymaps have an ''.map.gz'' extension, for example {{ic|us.map.gz}} is an American keymap. Just copy the keymap to {{ic|/usr/local/share/kbd/keymaps/personal.map.gz}} and ''gunzip'' it.}} |
||
− | |||
− | == ディレクティブの追加 == |
||
− | |||
− | Two kinds of directives are required in this personal keymap. First of all, the keycode directives, which matches the format seen in the default keymaps. These directives associate a keycode with a keysym. Keysyms represent keyboard actions. The actions available include outputting character codes or character sequences, switching consoles or keymaps, booting the machine, and many other actions. A complete list can be obtained with |
||
− | |||
− | # dumpkeys -l |
||
− | |||
− | Most keysyms are them are intuitive. For example, to set key 112 to output an 'e', the directive will be: |
||
− | |||
− | keycode 112 = e |
||
− | |||
− | To set key 112 to output a euro symbol, the directive will be: |
||
− | |||
− | keycode 112 = euro |
||
− | |||
− | Some keysym are not immediately connected to a keyboard actions. In particular, the keysyms prefixed by a capital F and one to three digits (F1-F246) constituting a number greater than 30 are always free. This is useful directing a hotkey to output a sequence of characters and other actions: |
||
− | |||
− | keycode 112 = F70 |
||
− | |||
− | Then, F70 can be bound to output a specific string: |
||
− | |||
− | string F70 = "Hello" |
||
− | |||
− | When key 112 is pressed, it will output the contents of F70. In order to execute a printed command in a terminal, a newline escape character must be appended to the end of the command string. For example, to enter a system into hibernation, the following keymap is added: |
||
− | |||
− | string F70 = "sudo /usr/sbin/hibernate\n" |
||
− | |||
− | === その他の例 === |
||
− | |||
− | * To make the Right Alt key same as Left Alt key (for Emacs), use the following line in your keymap. It will include the file {{ic|/usr/share/kbd/keymaps/i386/include/linux-with-two-alt-keys.inc}}, check it for details. |
||
− | |||
− | include "linux-with-two-alt-keys" |
||
− | |||
− | * To swap CapsLock with Escape (for Vim), remap the respective keycodes: |
||
− | |||
− | keycode 1 = Caps_Lock |
||
− | keycode 58 = Escape |
||
− | |||
− | * To make CapsLock another Control key, remap the respective keycode: |
||
− | |||
− | keycode 58 = Control |
||
− | |||
− | * To swap CapsLock with Left Control key, remap the respective keycodes: |
||
− | |||
− | keycode 29 = Caps_Lock |
||
− | keycode 58 = Control |
||
− | |||
− | == 変更の保存 == |
||
− | |||
− | In order to make use of the personal keymap, it must be loaded with ''loadkeys'': |
||
− | |||
− | $ loadkeys /usr/local/share/kbd/keymaps/personal.map |
||
− | |||
− | However this keymap only active for the current session. In order to load the keymap at boot, specify the full path to the file in {{ic|KEYMAP}} variable in {{ic|/etc/vconsole.conf}}. The file does not have to be gzipped as the official keymaps provided by {{Pkg|kbd}}. |