You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Logitech K380键盘在Ubuntu 22.04.1 LTS系统下的键位映射及宏设置方案咨询

Logitech K380键盘在Ubuntu 22.04.1 LTS系统下的键位映射及宏设置方案咨询

Hi there! Let's tackle your Logitech K380 issues on Ubuntu 22.04.1 LTS step by step—since Logitech's official software doesn't play nice with Linux, we've got some solid open-source alternatives to get your keys behaving exactly how you want.

一、调整F1-F12键的默认行为

Most Logitech keyboards default to using F1-F12 as media keys (like volume control or play/pause), but you can switch them to act as standard function keys permanently:

  • 方法1:临时快捷键切换(应急用)
    Hold the Fn key and press the corresponding F key to toggle between media and standard function mode temporarily.
  • 方法2:GNOME Tweaks图形化设置(适合GNOME桌面)
    First install the tool:
    sudo apt install gnome-tweaks
    
    Open GNOME Tweaks, navigate to Keyboard & Mouse > Additional Keyboard Settings, then find Function Key Behavior and select "Function Keys First". Now F1-F12 will work as standard function keys by default, and you'll need to press Fn+F key to access media functions.
  • 方法3:xmodmap命令行配置(通用所有桌面环境)
    1. Open a terminal and run xmodmap -pke | grep F1 to find the keycode for F1 (it usually looks like keycode 67 = F1 F1 F1 F1 XF86AudioMute XF86AudioMute—here 67 is the keycode).
    2. Create a configuration file:
      touch ~/.Xmodmap
      
    3. Add lines for each F key (replace the keycode with your own):
      echo "keycode 67 = F1 F1 F1 F1 XF86AudioMute XF86AudioMute" >> ~/.Xmodmap
      echo "keycode 68 = F2 F2 F2 F2 XF86AudioLowerVolume XF86AudioLowerVolume" >> ~/.Xmodmap
      # Repeat this pattern for F3 to F12
      
    4. Apply the changes immediately with:
      xmodmap ~/.Xmodmap
      
    This configuration will load automatically when you log in next time.

二、互换左Ctrl和左Win键

Swapping these two keys is straightforward—here are three reliable methods:

  • 方法1:GNOME Tweaks(最简单的图形化方式)
    Open GNOME Tweaks, go to Keyboard & Mouse > Additional Keyboard Settings, then look for Ctrl Key Position and select "Swap Ctrl and Win". The change takes effect right away.
  • 方法2:xmodmap命令行配置
    1. Create or edit the ~/.Xmodmap file:
      nano ~/.Xmodmap
      
    2. Paste these lines (37 is the default keycode for left Ctrl, 133 for left Win—use xev to confirm yours if needed):
      clear control
      clear mod4
      keycode 37 = Super_L NoSymbol Super_L
      keycode 133 = Control_L NoSymbol Control_L
      add control = Control_L Control_R
      add mod4 = Super_L Super_R
      
    3. Save and exit, then apply with xmodmap ~/.Xmodmap.
  • 方法3:系统键盘设置(GNOME)
    Open Settings > Keyboard > Keyboard Shortcuts > View and Customize Shortcuts, scroll to the bottom and select Custom Shortcuts. While this works, it's less efficient than the above methods for swapping modifier keys.

三、设置宏和自定义键位映射

For macros and advanced key remapping, these tools are your best bets:

  • AutoKey(新手友好的图形化工具)
    1. Install it:
      sudo apt install autokey-gtk  # For GNOME/Xfce; use autokey-qt for KDE
      
    2. Create a macro:
      • Open AutoKey, right-click My Phrases > New > Phrase. Name it something descriptive (like "System Update").
      • In the content box, type the command or text you want the macro to output (e.g., sudo apt update && sudo apt upgrade).
      • Go to the Trigger tab, click Add, select Hotkey, and set your desired shortcut (like Ctrl+Alt+U).
    3. For key remapping: Create a new Script instead of a phrase, then use code like keyboard.send_keys("<ctrl>+c") to map a key to a combination, then set the trigger key to the one you want to modify.
  • xbindkeys + xdotool(进阶命令行工具)
    1. Install the tools:
      sudo apt install xbindkeys xbindkeys-config xdotool
      
    2. Open xbindkeys-config (the graphical interface), click Add, then set the key you want to remap and the command to trigger. For example, to map F13 to open a new terminal tab, use the command xdotool key ctrl+shift+t.

备注:内容来源于stack exchange,提问作者user3277459

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.23 08:15:30