Config keyboard » Historie » Version 1
Jeremias Keihsler, 13.01.2017 09:42
1 | 1 | Jeremias Keihsler | h1. changing keyboard layout |
---|---|---|---|
2 | |||
3 | |||
4 | taken from http://askubuntu.com/questions/296155/how-can-i-remap-keyboard-keys |
||
5 | |||
6 | To simply swap two keys functions: From Terminal run xev and then press F9 which would give something like Terminal window showing F9 KeyPress event |
||
7 | |||
8 | Doing the same for PrtSc did not give any output in xev for me (or i could not find the "KeyPress event") so i used Argusvision's advice for using the Custom Shortcuts in All Settings but doing so in order to disable PrtSc as screenshot button by reassigning as Shift + Alt then tried pressing again which gave me keycode 107 for PrtSc in xev like so Terminal window showing PrtSc KeyPress event |
||
9 | |||
10 | Repeating the process for all four keys gave me |
||
11 | |||
12 | F9 = keycode 75 |
||
13 | PrtSc = keycode 107, action Print |
||
14 | F10 = keycode 76 |
||
15 | Scroll Lock = keycode 127, action Pause |
||
16 | |||
17 | To change a keys function we need to know the keycode of the NEW key being pressed and the "action" of the OLD or existing key for that function. |
||
18 | |||
19 | Now that we have the key codes for identifying the keys we now make the system do what we want by using xmodmap and as we know F9 has "keycode 75" and PrtSc has the action of "Print" all we need to do is |
||
20 | xmodmap -e "keycode 75 = Print" |
||
21 | to make the F9 key behave as if the PrtSc key has been pressed. i.e. the keycode stays the same but pressing the F9 key will have different results. |
||
22 | Using xev with Scroll Lock also gave |
||
23 | Terminal window showing Scroll Lock KeyPress event |
||
24 | |||
25 | which confirms the "action" for the Scroll Lock key is "Pause" so for making the F10 act as Scroll Lock trying |
||
26 | xmodmap -e "keycode 76 = Pause" should give the desired results. |
||
27 | That is until you log out or shutdown etc so what we have to do after confirming the commands |
||
28 | xmodmap -e "keycode 75 = Print" |
||
29 | |||
30 | xmodmap -e "keycode 76 = Pause" |
||
31 | |||
32 | do give the desired results is sort out SysRec which is modified PrtSc and swap over the other buttons so we do not have multiple instances of same key action . Adding |
||
33 | xmodmap -e "keycode 107 mod1 = F9 Sys_Req" |
||
34 | should swap F9 to where PrtSc was keeping the modified SysReq (Alt + PrtSc) again we can use xev to help verify this. |
||
35 | Swapping the Scroll Lock and F10 buttons is easier xmodmap -e "keycode 127 = F10" |
||
36 | |||
37 | After making sure that when running |
||
38 | xmodmap -e "keycode 75 = Print" |
||
39 | |||
40 | xmodmap -e "keycode 107 mod1 = F9 Sys_Req" |
||
41 | |||
42 | xmodmap -e "keycode 76 = Pause" |
||
43 | |||
44 | xmodmap -e "keycode 127 = F10" |
||
45 | does indeed do what is intended all that is left to do is get this happening at startup time. To do this run |
||
46 | xmodmap -pke|egrep -e '(F9|Print)' |
||
47 | which gave me |
||
48 | some more text |
||
49 | we are only interested in the keycodes 75 and 107. Do the same for |
||
50 | xmodmap -pke|egrep -e '(F10|Pause)' |
||
51 | which gave me |
||
52 | even more text |
||
53 | and we are only interested in the keycodes 76 and 127. |
||
54 | |||
55 | Create a new text document with your favourite text editor copy and paste the relevant information |
||
56 | |||
57 | keycode 75 = Print NoSymbol Print |
||
58 | keycode 107 = F9 Sys_Req F9 Sys_Req |
||
59 | keycode 76 = Pause NoSymbol Pause |
||
60 | keycode 127 = F10 NoSymbol F10 |
||
61 | |||
62 | naming the file as .Xmodmap and saving it in your Home directory would allow you to run the changes simply by logging on after rebooting. |
||
63 | |||
64 | In my actual case i exchanged Home with Prior and End with Next: |
||
65 | keycode 112 = Home |
||
66 | keycode 117 = End |
||
67 | keycode 110 = Prior |
||
68 | keycode 115 = Next |
||
69 | |||
70 | <pre><code class="bash"> |
||
71 | xmodmap -e "keycode 112 = Home" |
||
72 | xmodmap -e "keycode 117 = End" |
||
73 | xmodmap -e "keycode 110 = Prior" |
||
74 | xmodmap -e "keycode 115 = Next" |
||
75 | </code></pre> |