修改 Win 快捷键适配 macOS

一. 键盘管理器 (软件安装)

写在开头: 记住, 修改的越多 BUG 越多

  • 下载 PowerToys

点击 https://github.com/microsoft/PowerToys/releases 进行下载

(由于目前还是预览版, 需要到 Github 进行下载)

  • 下载 Sharpkeys

在这里插入图片描述

1. 单按键修改 (Sharpkeys)

!!! UPDATE: PowerToys 的单键修改 bug 太多, 已替换为 Sharpkeys (查找良久, 最终选定这个)

  • 安装
winget install -e RandyRants.SharpKeys

在这里插入图片描述

Alt -> Ctrl (替代 cmd 键)
Win -> Alt (替代 opt 键)
Caps -> ESC (Vim 用得多就 ESC, 用的少可以设置为 Ctrl)
(可选) 菜单键 -> Win (很多键盘没菜单键, 可忽略)

这里我没有将 Win 键重新映射, 因为开始菜单可以使用快捷键 Ctrl + ESC, 任务管理器可以使用 Ctrl+ Shift + ESC
如果使用 Power toys, 改键后原来的 Win (物理) + L 锁定依然可用, 但 Win + X 等其他 Win 快捷键就不行了 m$ 保留了这一点, 这样你才知道你用的是… 如果使用 Sharp keys, 通过注册表方式改键, 不会有这个问题
如果 Win 键是刚需, 可以额外设置 Ctrl -> Win. 我这里考虑到使用频率, 并没有这样设置

2. 组合快捷键修改

当前使用 PowerToys, 有 BUG 一直存在, 官方大概率也不会修
尝试迁移到 AutoHotkey, 但 Ctrl+Tab 映射到 Alt+Tab 有点问题. 目前只有这样了 (在 Win 上浪费时间不太值)

将窗口切换修改为 Ctrl + tab
关闭程序修改为 Ctrl + q (我后来移除掉了, 有快捷键被占用)
关闭当前页面修改为 Ctrl + w

Alt+Backspace to Ctrl+Backspace
Alt+Shift+Left to Ctrl+Shift+Left
Alt+Shift+Right to Ctrl+Shift+Right
Ctrl(Left)+Space to Win+Space
Ctrl(Left)+Up to Win(Right)+Tab
Ctrl(Right)+Tab to Alt+Tab
Ctrl(Right)+Up to Win(Left)+Tab

Ctrl(Left)+A to Home in chrome.exe
Ctrl(Left)+E to End in chrome.exe
Ctrl(Right)+Y to Ctrl+H in chrome.exe
Ctrl(Right)+[ to Alt+Left in chrome.exe
Ctrl(Right)+] to Alt+Right in chrome.exe
Ctrl(Right)+Shift+H to Alt+Home in chrome.exe

Ctrl(Right)+0 to Alt+0 clion64.exe,idea64.exe
...
Ctrl(Right)+6 to Alt+6 clion64.exe,idea64.exe
Ctrl(Right)+9 to Alt+9 clion64.exe,idea64.exe
Ctrl(Right)+, to Ctrl+Alt+S clion64.exe,idea64.exe
Alt(Right)+T to Ctrl(Right)+T clion64.exe,idea64.exe
Ctrl(Left)+Enter to Alt+Insert clion64.exe,idea64.exe

Ctrl(Left)+H to Alt(Left)+F4 wechat

在这里插入图片描述


3. 直观展示

在这里插入图片描述

二. 解决 PowerToys 的键盘管理器 Shortcuts 失效的问题


  • BUG-1 (2024.11.23 斐波那契日更新): 按下 Alt + Tab 后 (因为改键, 实际上是 Ctrl + Tab), Alt (Ctrl) 键未释放)
    解决方案: 把 remap 的 Ctrl 键改为 Ctrl (right) 就行
  • 来源: https://github.com/microsoft/PowerToys/issues/17035 (Keyboard shortcut causes Ctrl key to act stuck)
    This happens when you use Ctrl+another key, in the mapping, instead of Ctrl(Left) or Ctrl(Right).
    Then if you use Ctrl(Right) as the actual shortcut, it won’t register you’ve actually released the key.

  • BUG-2 现象: Windows开机之后PowerToys能正常使用, 但是打开微信之后设置好的快捷键映射就全部失效了

失效时机:

  1. 启动微信
  2. 进入“订阅号”点开任一公众号

以上 2 点都会导致 keyboard manager 的 shortcuts 失效 (remap 不受影响)

  • 解决办法 1
打开微信 -> 左下角三条杠 -> 设置 -> 快捷键 -> 取消勾选{检测快捷键}
  • 解决办法 2 (比较麻烦, 每次出现问题都得操作一遍)
ctrl + alt + del
然后再退出 (cancel)
  • 解决办法 3 (来自 @ffwindy)

当打开微信的时候,F22 按键被按下并没有释放,因此键盘管理器失效,通过软件释放 F22 之后键盘管理器映射就可以重新使用
在这里插入图片描述

(将 F22 映射到 disable 解决打开微信键盘失灵的问题)

可能原因: weixin 设置里默认勾选了{检测快捷键}, 程序一直在后台检测, 而同时 powerToy 也在检测, 双方冲突所以就会莫名奇妙失效.

相关 issue: #9300 #16173 #26498 #21877 (推荐直接看21877)

三. MacOS 强制退出

  • Normal (cmd+opt+esc)

Command+Option+Escape

  • Active (cmd+opt+shift+esc)

Command+Option+Shift+Escape

  • Dock (opt+ctrl+click in dock)

Option + Right Click on an apps icon in the Dock

  • 苹果标志 (shift+click)

Hold the Shift Key and click on the “苹果” Apple menu to find “Force Quit [Application Name]”.

  • Commands
# killall [processname]
killall Safari

四. 改变鼠标滚轮方向 (Mac 方式, 又称自然方式 Natural Mode)

参考: Reference

Step 1: Open Windows PowerShell in Administrator Mode. You can do this by going to Start Menu, type PowerShell, and click Run as Administrator.

Step 2: Copy the following code and paste it in the command line of Windows PowerShell:

$mode = Read-host "How do you like your mouse scroll (0 or 1)?"; Get-PnpDevice -Class Mouse -PresentOnly -Status OK | ForEach-Object { "$($_.Name): $($_.DeviceID)"; Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Enum\$($_.DeviceID)\Device Parameters" -Name FlipFlopWheel -Value $mode; "+--- Value of FlipFlopWheel is set to " + (Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Enum\$($_.DeviceID)\Device Parameters").FlipFlopWheel + "`n" }

Step 3: It will ask how do you like your mouse to scroll.

Downward wheel motion makes the page…
0 - Move up so you see contents below (Default Mode, Windows behavior)
1 - Move down so you can see contents above (Natural Mode, Mac behavior, reverse mode)

Type the number that corresponds to your scroll preference.

Step 4: Restart your computer. Your settings will take effect after you restart.

In a nutshell, the script detects all your mouse devices that’s registered in your device and sets the FlipFlopWheel registry key to the value you selected. The script makes it easy for you to do this without opening Windows Registry and searching the device ID of your mouse which is error prone and confusing.

五. Win10/11 微软拼音导入小鹤双拼方案

Step 1: 保存为 .reg 后缀

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\InputMethod\Settings\CHS]
"Enable Cloud Candidate"=dword:00000000
"Enable Dynamic Candidate Ranking"=dword:00000001
"EnableExtraDomainType"=dword:00000001
"Enable self-learning"=dword:00000001
"EnableSmartSelfLearning"=dword:00000001
"EnableLiveSticker"=dword:00000000
"Enable EUDP"=dword:00000001
"Enable Double Pinyin"=dword:00000001
"UserDefinedDoublePinyinScheme0"="xiaohe*2*^*iuvdjhcwfg^xmlnpbksqszxkrltvyovt"
"DoublePinyinScheme"=dword:0000000a

(适配登录后复制的情况)

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\InputMethod\Settings\CHS]
"Enable Cloud Candidate"=dword:00000000
"Enable Dynamic Candidate Ranking"=dword:00000001
"EnableExtraDomainType"=dword:00000001
"Enable self-learning"=dword:00000001
"EnableSmartSelfLearning"=dword:00000001
"EnableLiveSticker"=dword:00000000
"Enable EUDP"=dword:00000001
"Enable Double Pinyin"=dword:00000001
"UserDefinedDoublePinyinScheme0"="xiaohe*2*^*iuvdjhcwfg^xmlnpbksqszxkrltvyovt"
"DoublePinyinScheme"=dword:0000000a

保存为 .reg 后缀文件

Step 2: 双击该文件执行

六. 缩放 200% (both 27 inch)

  • 4k to 200%
    在这里插入图片描述
  • 1080p to 100%
    在这里插入图片描述

七. 在输入法中添加单词字典

  1. 输入法
    在这里插入图片描述
  2. lexicon 字典, 词典
    在这里插入图片描述
  3. user defined phrases
    在这里插入图片描述
    在这里插入图片描述

ps: 在词后面可以加上空格, 这样只用按一次空格就有间隔了

  • 摘要
cpu CPU
mem Mem
disk
list
set
queue
stack
heap
bash
bd 
git 
go
how 
java Java
jira 
python Python
shell
zsh
todo
fixme
fixup
cas CAS
mysql MySQL
redis Redis
mybatis MyBatis
springboot SpringBoot
springcloud SpringCloud
rocketmq RocketMQ
kafka Kafka
netty Netty
redission Redission
hashmap HashMap
jvm JVM
juc JUC
sql SQL
linux Linux
dubbo Dubbo
select
from
epoll
ps ps: 

不能以 u / v 开头
在这里插入图片描述

八. 卸载 Xbox Game Bar

没洁癖, 不在意这个的话, 可以不删除

  • PowerShell 中运行 (管理员)
Get-AppxPackage Microsoft.XboxGamingOverlay | Remove-AppxPackage

(补充) 如果有弹窗
在这里插入图片描述

  • 继续执行
reg add HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\GameDVR /f /t REG_DWORD /v "AppCaptureEnabled" /d 0
reg add HKEY_CURRENT_USER\System\GameConfigStore /f /t REG_DWORD /v "GameDVR_Enabled" /d 0

来源: Properly uninstalling xbox gamebar and resolve ms-gaming-overlay-link popup on windows 11

如果是为了录屏的话, 更好的选择是 微软自带的 Snipping Tool 截屏工具 (包含录屏)

九. Finger Maps

指位图

  • 参考

在这里插入图片描述
在这里插入图片描述

  • 换了一个支持 via 的键盘 2024/12/7

为了兼容 win 和 mac, 在 win 系统里改了键, 比如 alt to ctrl, win to alt, 第二层的 win 是为了快速锁屏放那的
在这里插入图片描述
照搬 hhkb 的第二层, 其中 scroll 和 pause, 会被 mac 识别成 F14, F15, 所以可以控制亮度
在这里插入图片描述

  • 打字原则 (最重要的就是 Rollover: 累积 滚动增加 [车辆]倾翻)
  1. [move less] The minimum movement principle.
  2. [don’t wait] The Rollover Technique.
  3. [don’t distract] Focus on Accuracy.
  • 第 6 版 (2024/12/7) 尽量减轻食指的负担, C 键改为中指 Lukas 的评论

在这里插入图片描述

  • 第 5 版 (2024/08/15)

在这里插入图片描述

  • 第 4版 - V2

在这里插入图片描述

  • 第 4 版

在这里插入图片描述

  • 第 3 版

在这里插入图片描述

  • 第 2 版

在这里插入图片描述

  • 第 1 版
    在这里插入图片描述

<think>嗯,用户问的是在Qt程序中,键盘事件触发其他软件快捷键的问题。首先,我需要回忆一下Qt的事件处理机制。Qt里,键盘事件通常是先由当前获得焦点的控件处理,如果没被处理的话,会传递给父控件,依此类推。但有时候,如果程序没有正确处理这些事件,可能会导致事件传递到系统层面,从而触发其他应用的快捷键。 接下来,用户可能遇到的情况是,当他们的Qt应用运行时,按下某个键,结果另一个软件的快捷键被激活了。比如按Ctrl+C,可能触发了剪贴板操作,即使应用本身有处理这个快捷键。这时候用户会疑惑,为什么自己的程序没有拦截这个事件,反而系统其他软件响应了。 我需要考虑几个可能的原因。首先,是否在Qt中正确重写了事件处理函数,比如keyPressEvent,并且调用了event->accept()来标记事件已处理。如果事件没有被accept,可能会继续传播。其次,检查是否使用了QShortcut或者QAction来设置快捷键,这些高级别的方法可能更容易正确捕获事件。另外,可能需要关注事件过滤器(event filter),是否有正确安装和实现,以确保在事件传递到其他控件前被处理。 还有一个可能性是,当Qt应用没有正确处理某些系统级的热键,比如全局快捷键,系统可能会捕获这些事件。比如,某些组合键被操作系统或桌面环境设置为全局快捷键,这时候即使应用处理了事件,系统也会同时响应。这时候需要用户检查系统设置,看看是否有冲突的全局快捷键。 解决方案方面,首先建议用户确保在事件处理函数中调用accept(),防止事件继续传播。其次,使用Qt提供的快捷键机制,如QShortcut,而不是手动处理所有按键。另外,检查是否有必要使用事件过滤器来提前拦截事件。对于系统级快捷键冲突,可能需要用户调整系统设置,或者在程序中重新注册全局快捷键,但这可能涉及平台特定的代码,比较复杂。 需要提醒用户,处理系统级快捷键可能因操作系统而异,比如WindowsmacOS和Linux可能有不同的行为。这时候需要跨平台的考虑,或者针对特定系统进行适配。 最后,要确保示例代码正确,比如在重写keyPressEvent时,正确处理事件,并在必要时调用父类的实现,避免破坏原有的事件传递链。同时,注意事件传播的机制,比如在Qt中,事件是先传递给子控件,再向上传递,所以焦点控件的处理是否正确也很关键。</think>在Qt程序中,键盘事件意外触发其他软件快捷键的问题,通常与事件传播机制和操作系统的事件处理逻辑有关。以下是逐步分析和解决方案: 1. **事件传递机制** Qt的键盘事件遵循`焦点传递`原则: - 当前获得焦点的窗口部件(QWidget)优先处理事件 - 未处理的事件会向父级窗口传播 - 最终未被处理的事件会被发送到操作系统 2. **常见原因** ✅ **未正确标记事件为已接受** ```cpp void MyWidget::keyPressEvent(QKeyEvent *event) { if (event->key() == Qt::Key_A) { // 处理逻辑... event->accept(); // ✔ 关键语句 } else { event->ignore(); // ✖ 不处理时需显式忽略 } } ``` ✅ **全局快捷键冲突** 系统级快捷键(如Win/Mac的全局快捷键)优先级高于应用程序快捷键 3. **解决方案** (1) **显式处理事件** 在事件处理函数中必须调用`event->accept()` (2) **使用Qt快捷键框架** ```cpp QShortcut *shortcut = new QShortcut(QKeySequence("Ctrl+S"), this); connect(shortcut, &QShortcut::activated, [](){ qDebug() << "自定义快捷键触发"; }); ``` (3) **事件过滤器拦截** ```cpp bool MyFilterObject::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); if (keyEvent->key() == Qt::Key_F1) { // 处理逻辑... return true; // 阻止事件继续传播 } } return QObject::eventFilter(obj, event); } ``` 4. **系统级处理(进阶)** - Windows: 使用`RegisterHotKey`/`UnregisterHotKey` - macOS: 需要处理`NSEvent` - Linux(X11): 使用`XGrabKey` 5. **调试建议** 使用`qDebug() << "Event:" << event;`输出事件处理日志,确认: - 事件是否被正确捕获 - 事件传播路径是否符合预期 - 是否有多个控件同时响应同一事件 **典型场景示例**: 当同时按下`Alt+Tab`时,即使处理了该事件,Windows仍会执行窗口切换操作。这是因为系统全局快捷键的处理优先级高于应用程序,需要通过系统API注册全局快捷键才能覆盖。 建议优先使用Qt的快捷键框架处理常见组合键,对于需要拦截系统快捷键的特殊场景,需结合平台特定API实现。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值