centos7應用筆記:鍵盤重影射

centos7應用筆記:鍵盤重影射

我的鍵盤 右shift鍵 無法使用了。想使用 右alt鍵 代替。
查詢了一下 xmodmap 命令可以實現該功能。
以下是我的配置方法的記錄。

xmodmap 配置文件

xmodmap 配置文件的作用是:交換 右shift鍵右alt鍵
可以參考 manpage 中的例子。

創建一個 xmodmap 配置文件:
/etc/xmodmap.config

xmodmap 配置文件內容:

! swap Alt_R and Shift_R
remove Shift = Shift_R
remove Mod1 = Alt_R
keysym Shift_R = Alt_R
keysym Alt_R = Shift_R
add Shift = Shift_R
add Mod1 = Alt_R

xmodmap 指令的使用

xmodmap 執行配置文件。交換 右shift鍵右alt鍵

xmodmap /etc/xmodmap.config

將以上的指令寫入 /etc/profile 中。就可以再開機的時候自動配置了。

注意:

如果再執行一次 xmodmap /etc/xmodmap.config。兩鍵又會交換回來的。

xmodmap 其他指令。

使用 xmodmap 查看 modifier 鍵值影射。

xmodmap
>	xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):
>
>	shift       Shift_L (0x32),  Shift_R (0x6c)
>	lock        Caps_Lock (0x42)
>	control     Control_L (0x25),  Control_R (0x69)
>	mod1        Alt_R (0x3e),  Alt_L (0x40),  Meta_L (0xcd)
>	mod2        Num_Lock (0x4d)
>	mod3
>	mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
>	mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

查看 keycode

使用 xev 指令可以查看 keycode 和 keyname。

xev | grep keycode
>	state 0x0, keycode 38 (keysym 0x61, a), same_screen YES,					# key `a` pressed
>	state 0x0, keycode 38 (keysym 0x61, a), same_screen YES,					# key `a` released
>	state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,			# key `Control_L` pressed
>	state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,			# key `Control_L` released
>	state 0x0, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,			# key `Shift_L` pressed
>	state 0x1, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,			# key `Shift_L` released
>	state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,				# key `Return` pressed
>	state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,				# key `Return` released

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章