You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多
文档控制台
免费开始使用

如何在ThinkPad X1 Yoga上复刻苹果键盘Fn组合键导航功能?

How to Map Fn+Arrow Keys to Home/End/PageUp/PageDown on ThinkPad X1 Yoga (Linux)

Hey there, I totally get missing that Apple keyboard navigation convenience—let's get your ThinkPad set up to match it. Below are two reliable methods depending on whether you're using X11 or Wayland (most modern Linux desktops use Wayland these days, like the default GNOME setup on the X1 Yoga).

Method 1: For X11 Environments (e.g., Xfce, older GNOME)

We’ll use xmodmap to remap the key combinations directly:

  1. Identify your keycodes
    Open a terminal and run xev. A small window will pop up—focus it, then press each Fn+arrow key pair one by one. Look for lines like keycode 113 (keysym 0xff50, Home) (your actual keycodes might differ). Jot down the keycode for each combination.

  2. Create an xmodmap config file
    Open ~/.Xmodmap in your favorite text editor (e.g., nano ~/.Xmodmap) and add lines like this, replacing the placeholder keycodes with the ones you found:

    ! Map Fn+Left to Home
    keycode 113 = Home NoSymbol Home
    ! Map Fn+Right to End
    keycode 114 = End NoSymbol End
    ! Map Fn+Up to Page Up
    keycode 111 = Prior NoSymbol Prior
    ! Map Fn+Down to Page Down
    keycode 116 = Next NoSymbol Next
    

    The NoSymbol entry handles modifier combinations, and repeating the target key ensures the mapping works with Shift (e.g., Shift+Fn+Left selects text to the start of the line).

  3. Apply and persist the mapping
    Run xmodmap ~/.Xmodmap in the terminal to test it immediately. If it works, set it to run on startup:

    • Add xmodmap ~/.Xmodmap to your desktop environment’s startup applications list.
    • If you use startx, add that line to ~/.xinitrc.

Method 2: For Wayland Environments (e.g., Modern GNOME)

Wayland doesn’t support xmodmap, so we’ll use ydotool (to simulate key presses) and sxhkd (to listen for key combinations) as a flexible workaround:

  1. Install required tools
    Open a terminal and install them with your package manager:

    # Debian/Ubuntu-based systems
    sudo apt install sxhkd ydotool
    
    # Fedora/RHEL-based systems
    sudo dnf install sxhkd ydotool
    
    # Arch-based systems
    sudo pacman -S sxhkd ydotool
    
  2. Create the sxhkd config
    First, create the config directory if it doesn’t exist, then open the config file:

    mkdir -p ~/.config/sxhkd
    nano ~/.config/sxhkd/sxhkdrc
    

    Add these lines (use wev—Wayland’s event viewer—to find your Fn key’s actual name if XF86LaunchA doesn’t work):

    # Fn+Left → Home
    XF86LaunchA + Left
        ydotool key Home
    
    # Fn+Right → End
    XF86LaunchA + Right
        ydotool key End
    
    # Fn+Up → Page Up
    XF86LaunchA + Up
        ydotool key Page_Up
    
    # Fn+Down → Page Down
    XF86LaunchA + Down
        ydotool key Page_Down
    
  3. Start sxhkd on boot
    Create a systemd user service to run sxhkd automatically:

    nano ~/.config/systemd/user/sxhkd.service
    

    Paste this content:

    [Unit]
    Description=Simple X hotkey daemon
    After=graphical-session.target
    
    [Service]
    ExecStart=/usr/bin/sxhkd
    Restart=always
    
    [Install]
    WantedBy=graphical-session.target
    

    Enable and start the service:

    systemctl --user enable sxhkd.service
    systemctl --user start sxhkd.service
    

Quick Test

After setting up either method, open a text editor (like Gedit or VS Code) and try pressing Fn+Left/Right/Up/Down—you should jump to the start/end of the line, or scroll up/down pages just like your old Apple keyboard.

内容的提问来源于stack exchange,提问作者Naftuli Kay

火山引擎 最新活动