Ubuntu modifies the capslock key, which is esc when used alone, and ctrl+ when used in combination

  1. The following part can interchange capslock with ctrl

Put the following code in ~/.Xmodmap,

remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L

Pay attention to capitalization

2. After seeing the answer of a netizen on Zhihu, you can modify it by the following methods

Author: lee moo
Link: http://www.zhihu.com/question/28643416/answer/41668224
Source: Zhihu

add Control = Caps_Lock
remove Lock = Caps_Lock
keysym Caps_Lock = Escape

The above is the method of xmodmap. This implementation is not very good! However, in the spirit of "as long as I can use it cool, I would rather fight until dawn", I found another method, but it seems that it can only be used under X. To use the system's keymap

1. Map Capslock to Esc,

2. Then use xcape - e 'Escape=Control_L' to achieve this.

Here is the C link to the collection : https://github.com/ICEleemoo/xcape

I always feel that there may be other implementations. For example, modifying some keymap related files, etc..., but I still hope that the great gods can find a better way.

Thanks to the author
 
But after feeling it for a while, I found that the capslock key is triggered when it is pressed, so in some cases, the key combination cannot be used after exiting, so I bound esc to the shift key
The uppercase key capslock and the right ctrl function are interchanged, so that the left ctrl can still be used normally, the left shift is the esc key in the normal state, and the shift key is still used in combination.

remove Lock = Caps_Lock
remove Control = Control_R
keysym Control_R = Caps_Lock
keysym Caps_Lock = Control_R
add Lock = Caps_Lock
add Control = Control_R
keysym Shift_L = Escape

 

http://www.programgo.com/article/49642670420/

Based on the concept of "it is better to teach a man to fish than to give a man a fish", this article will give the conclusion and the method to get the conclusion.
Under the influence of Linux philosophy, Linux programmers often have some special ideas to improve work efficiency. Such as writing repetitive mechanical labor into a script, or the content of this article - changing key positions.
HHKB is the preferred keyboard for vimer under Linux. Regardless of the feel of capacitive keyboard, its key position is designed for vim: pull ESC, BackSpace, and put Ctrl to the left of A, and vimer needs to press Ctrl all day long, so that The design will greatly reduce the fatigue of the little finger. But the price of this cool keyboard is as high as 2000RMB, and it is easy to be said by colleagues to "install B".
Before buying HHKB, I tried to use KBC POKER to realize the key position of HHKB; after buying HHKB, wow, this set of configuration is even more essential, because I can no longer use ordinary keyboards.
 
Next, I will talk about the specific implementation. My OS is Ubuntu 10.04 LTS, which is implemented through xmodmap, which is valid for the entire X desktop.
 
1. How to implement
First look at the current key positions of the system (and the representation of each key):
# xmodmap -pke > /tmp/map
Edit the /tmp/map file and find the following 4 lines:
#----------------------------------------------------------------------
keycode   9 = Escape NoSymbol Escape
keycode  37 = Control_L NoSymbol Control_L
keycode  49 = grave asciitilde grave asciitilde
keycode  66 = Caps_Lock NoSymbol Caps_Lock
#----------------------------------------------------------------------
It is the corresponding ESC, left CTRL, accent and CAPS_LOCK keys.
 
My purpose is to swap ESC and accent, CAPS_LOCK is mapped to left CTRL, modify
~/.xmodmaprc
#----------------------------------------------------------------------
!
! Swap Caps_Lock and Control_L
!
remove Lock = Caps_Lock
!remove Control = Control_L
!keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
!add Lock = Caps_Lock
add Control = Control_L
!
!  keycode   9 = grave asciitilde grave asciitilde
!  keycode  49 = Escape NoSymbol Escape
keysym Escape = grave asciitilde grave asciitilde
keysym grave = Escape
#----------------------------------------------------------------------
Then restart xserver to log in to the current user.
 
When the gnome desktop starts, it will detect the configuration files matching ~/.xmodmap*. If a new configuration file is found, a dialog box will automatically pop up to select which configuration files to load.
Then, you're done!
The usage of the specific script can be man xmodmap, but it should not be too difficult to draw the scoop according to the gourd.
 
 
2. If you have moved Ubuntu's keyboard options, there are certain key mapping options
If step 1 is successful, you may not need to read any further. However, if it doesn't work, it may be the following reasons.
But there are some keymap options in Ubuntu's keyboard options (for example, System-Preferences-Keyboard-Layout-Options-"Ctrl Key Position" select "Make CapsLock an additional Ctrl"), and applying these options will be faster than xmodmap is later, causing them to override the settings of left CTRL and CAPS_LOCK.
Moreover, what is even more hateful is that if you have set the keyboard preference "Ctrl Key Position" in desktop/gnome/peripherals/keyboard (system-preferences-keyboard), there is no way to cancel this setting through the graphical interface. Even if it is set to "default", the system will reset the keys when starting the gnome desktop, and then overwrite my configuration in .xmodmaprc. This option needs to be cleared at this time.
 
a) Modify
~/.gconf/desktop/gnome/peripherals/keyboard/kbd/%gconf.xml
delete the following nodes
#----------------------------------------------------------------------
<li type="string">
<stringvalue>ctrl ctrl:swapcaps</stringvalue>
</li>
#----------------------------------------------------------------------
 
b) modify
~/.gconfd/saved_state
Delete all lines with "keyboard".
 
c) Write .xmodmaprc, then restart xserver (Ctrl+Alt+Backspace, if this shortcut is enabled), which will automatically write the configuration to ~/.gconfd/saved_state. Then it works every time you boot up.
 
 
3. What if .xmodmaprc is not loaded into the configuration
When you accidentally disable .xmodmaprc, or modify .xmodmaprc but nothing happens, you can try:
Revise
~/.gconf/desktop/gnome/peripherals/keyboard/general/%gconf.xml
delete the following nodes
#----------------------------------------------------------------------
<entry name="known_file_list" mtime="1315277419" type="list" ltype="string">
<li type="string">
<stringvalue>.xmodmaprc</stringvalue>
</li>
<li type="string">
<stringvalue>xmodmaprc</stringvalue>
</li>
</entry>
#----------------------------------------------------------------------
The next time you boot up, you can choose whether to load the configuration again.
 
The picture below shows HHKB (Delete is actually Backspace, and the block is actually Alt) and KBC POKER
 
 
 The final configuration is like this
remove Lock = Caps_Lock
remove Control = Control_R
keysym Control_R = Caps_Lock
keysym Caps_Lock = Control_R
add Lock = Caps_Lock
add Control = Control_R
keysym Escape = grave asciitilde grave asciitilde
keysym grave = Escape asciitilde

The esc key is changed to the `~ key, and the original `~ key is changed to the tab~ key

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324427137&siteId=291194637