是否可以在 Linux 上重新映射 Thinkpad USB 键盘的后退/前进键?

Gui*_*ado 9 linux usb keyboard thinkpad ubuntu

在我的 Thinkpad 笔记本电脑上,我可以轻松地将后退/前进键更改为其他键(我通常将它们映射到 PageDown/PageUp),因为它们有自己的键码(166 和 167):

xmodmap -e 'keycode 166=Prior'
xmodmap -e 'keycode 167=Next'
Run Code Online (Sandbox Code Playgroud)

但是,在我的 Thinkpad USB 键盘上,后退/前进键似乎分别硬映射到 Alt+Left 和 Alt+Right,因此我无法使用 xmodmap 重新映射它们。有没有其他方法可以重新映射它们?我已经尝试过 xautomation,但是没有用。

这是我按下前进键时“xev”向我显示的内容:

KeyPress event, serial 36, synthetic NO, window 0x4e00001,
    root 0xb4, subw 0x0, time 65023191, (16,-20), root:(641,33),
    state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 36, synthetic NO, window 0x4e00001,
    root 0xb4, subw 0x0, time 65023191, (16,-20), root:(641,33),
    state 0x8, keycode 114 (keysym 0xff53, Right), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 36, synthetic NO, window 0x4e00001,
    root 0xb4, subw 0x0, time 65023271, (16,-20), root:(641,33),
    state 0x8, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 36, synthetic NO, window 0x4e00001,
    root 0xb4, subw 0x0, time 65023271, (16,-20), root:(641,33),
    state 0x0, keycode 114 (keysym 0xff53, Right), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False
Run Code Online (Sandbox Code Playgroud)

Sle*_*Boy 0

  1. 安装xdotool
  2. 为要运行的按键命令创建脚本或 shell 别名 ( xdotool key --clearmodifiers Page_Down)
  3. 将该脚本/别名绑定到桌面环境的热键/快捷方式配置中发送的组合 (Alt+Left)。

请注意,在 gnome-control-center 中,似乎无法将USB 键盘的后退/前进按钮分配给快捷方式(您实际上可以分配它们,但映射到它的命令/操作永远不会被调用) /happen),所以你可能需要使用其他东西,比如 compiz 的命令插件。