Config keyboard » Historie » Revision 1
Revision 1/2
| Weiter »
Jeremias Keihsler, 13.01.2017 09:42
changing keyboard layout¶
taken from http://askubuntu.com/questions/296155/how-can-i-remap-keyboard-keys
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
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
Repeating the process for all four keys gave me
F9 = keycode 75
PrtSc = keycode 107, action Print
F10 = keycode 76
Scroll Lock = keycode 127, action Pause
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.
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
xmodmap -e "keycode 75 = Print"
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.
Using xev with Scroll Lock also gave
Terminal window showing Scroll Lock KeyPress event
which confirms the "action" for the Scroll Lock key is "Pause" so for making the F10 act as Scroll Lock trying
xmodmap -e "keycode 76 = Pause" should give the desired results.
That is until you log out or shutdown etc so what we have to do after confirming the commands
xmodmap -e "keycode 75 = Print"
xmodmap -e "keycode 76 = Pause"
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
xmodmap -e "keycode 107 mod1 = F9 Sys_Req"
should swap F9 to where PrtSc was keeping the modified SysReq (Alt + PrtSc) again we can use xev to help verify this.
Swapping the Scroll Lock and F10 buttons is easier xmodmap -e "keycode 127 = F10"
After making sure that when running
xmodmap -e "keycode 75 = Print"
xmodmap -e "keycode 107 mod1 = F9 Sys_Req"
xmodmap -e "keycode 76 = Pause"
xmodmap -e "keycode 127 = F10"
does indeed do what is intended all that is left to do is get this happening at startup time. To do this run
xmodmap -pke|egrep -e '(F9|Print)'
which gave me
some more text
we are only interested in the keycodes 75 and 107. Do the same for
xmodmap -pke|egrep -e '(F10|Pause)'
which gave me
even more text
and we are only interested in the keycodes 76 and 127.
Create a new text document with your favourite text editor copy and paste the relevant information
keycode 75 = Print NoSymbol Print
keycode 107 = F9 Sys_Req F9 Sys_Req
keycode 76 = Pause NoSymbol Pause
keycode 127 = F10 NoSymbol F10
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.
In my actual case i exchanged Home with Prior and End with Next:
keycode 112 = Home
keycode 117 = End
keycode 110 = Prior
keycode 115 = Next
xmodmap -e "keycode 112 = Home"
xmodmap -e "keycode 117 = End"
xmodmap -e "keycode 110 = Prior"
xmodmap -e "keycode 115 = Next"
Von Jeremias Keihsler vor fast 8 Jahren aktualisiert · 1 Revisionen