注意点,在设置之前, 由于不同的人惯用手不同,
如果有的人是左手,此时,基础按键应该设置为left ,即图中所示的深色的。
1 . 鼠标中键
这里的鼠标中键, 其实就是我们平时用的滚轮, 只不过我们基本叫他滚轮, 因为用它的时候,基本是来滚动的, 但他确实也是键, 也能按。
在 windows 中复制 粘贴通常 使用 ctrl + c, ctrl +v 完成, ubuntu 中也适用;
但是ubuntu 中的中键多了一项功能, 即自动粘贴; 那么便减少了原始的 ctrl +v 的这个步骤;
因为在很多 ide 中, ctrl +v 这些快捷键的功能 会被覆盖成其他的功能;
1.1 启用 鼠标中键
使用的方式如下:
- 选中需要复制的文本,
- 进行复制( 可使用 )
- 光标移动需要粘贴的位置, 按下鼠标中键。
1.2 关闭鼠标中键功能
安装和启动 gnome-tweaks。
由于不同的的 Ubuntu 版本中 UI 发生变化,
这里介绍使用 GNOME 工具, 关闭鼠标中键。
安装和启动 gnome-tweaks
sudo apt install gnome-tweaks
gnome-tweaks
在 keyboard & mouse 中关闭 Middle click paste 功能;
2. 鼠标按键功能的映射
然而,网路上, 有些人给出了使用 xmodmap 的方式,取消中键粘贴的功能;
xmodmap -e "pointer = 1 25 3 4 5 6 7 2"
这里记录一下 xmodmap 的作用
2.1 默认的映射关系
xmodmap 中, 是按照位置的先后顺序, 来分别代表各自的功能作用。
即前三个位置上, 是代表 鼠标的 左 中 右 这三个 按键;
指针映射表达式指定了指针按钮的顺序和行为。
数字代表指针的按钮 ID,它们在列表中的位置决定了物理按钮如何映射到逻辑按钮动作。
xmodmap -e "pointer = 1 2 3 4 5 6 7 8"
具体默认设置如下:
Default Button Mapping: The default pointer button mapping is typically 1 2 3 4 5 6 7, corresponding to:默认按钮映射:默认指针按钮映射通常是 1 2 3 4 5 6 7 ,对应于:
1: Left button 1 :左键
2: Middle button 2 :中键
3: Right button 3 :右键
4: Scroll wheel up4 :滚轮向上
5: Scroll wheel down5 : 滚轮向下
6, 7: Additional buttons (e.g., side buttons on some mice) 6, 7 :附加按钮(例如,某些鼠标的侧按钮)
2.2 自定义映射
如前面, 有些人通过将 第二个位置,即代表鼠标中键的功能 映射到一个物理不存在的id上, 通过这种方式来取消中键粘贴的功能, 其实是不合理, 万一某种情况下, 物理id 25的硬件存在了,便会出错。
xmodmap -e "pointer = 1 25 3 4 5 6 7 2"
Clarification of Positions 25 and 2:职位 25 和 2 的澄清:
-
Position in the list matters:列表中的位置很重要:
- The position in the
pointer
list determines which physical button performs the logical action.列表中的位置决定了哪个物理按钮执行逻辑操作。 - Position 2 (the second number in the list) specifies which physical button acts as the middle button.位置 2(列表中的第二个数字)指定哪个物理按钮作为中间按钮。
- Position 8 (the last number in the list) specifies which physical button acts as button 8 (if available).
- The position in the
位置 8(列表中的最后一个数字)指定哪个物理按钮充当原始位置8 上的功能(如果有的话)。
-
What does this mapping do?这是这个映射做什么?
- Button 25 is assigned to the second position in the list. This means Button 25 on your device now performs the middle button function (Button 2).按钮 25 被分配到列表的第二位。这意味着您设备上的按钮 25 现在执行中间按钮功能(按钮 2)。
- Button 2 is assigned to the eighth position in the list. This means Button 2 performs a different function based on its position (logical Button 8 in this case).按钮 2 分配到列表中的第八位。这意味着按钮 2 根据其位置执行不同的功能(在这种情况下为逻辑按钮 8)。
Implications:影响:
- Both Button 25 and Button 2 are mapped, but they represent different logical buttons due to their positions in the list.两个按钮 25 和按钮 2 都已映射,但由于它们在列表中的位置不同,它们代表不同的逻辑按钮。
- Button 25 is explicitly mapped to function as the middle button (logical Button 2).按钮 25 被明确映射为中间按钮(逻辑按钮 2)的功能。
- Meanwhile, Button 2 itself (the physical middle button) is remapped to perform the function of the eighth button.同时,按钮 2 本身(物理中间按钮)被重新映射以执行第八个按钮的功能。
Why might this be done?为什么可能会这样做?
- To remap a broken middle button:要将损坏的中部按钮重新映射:
- If your physical middle button (Button 2) is non-functional, this remaps another button (e.g., Button 25) to act as the middle button.如果您的物理中间按钮(按钮 2)无法使用,此功能会将另一个按钮(例如,按钮 25)重新映射为中间按钮。
- To change device behavior:要更改设备行为:
- You may want a specific button (like Button 25) to have the middle button’s functionality for easier access or ergonomic reasons.您可能希望某个特定按钮(如按钮 25)具有中间按钮的功能,以便更容易访问或出于人体工程学原因。
How to Check Button Numbers:如何检查按钮编号:
To understand which physical button corresponds to which button ID, you can use the command:要了解哪个物理按钮对应哪个按钮 ID,可以使用以下命令:
xev
- This opens a window where you can click each mouse button to see its assigned button ID.这打开了一个窗口,您可以在其中点击每个鼠标按钮以查看其分配的按钮 ID。
Recap:摘要:
- Button 25 now performs the middle button function.按钮 25 现在执行中间按钮功能。
- Button 2 (the physical middle button) is remapped to perform a different logical function (Button 8).按钮 2(物理中间按钮)被重新映射以执行不同的逻辑功能(按钮 8)。