# Keyboard shortcuts in editor break standard OSX shortcuts

**URL:** <https://meta.discourse.org/t/keyboard-shortcuts-in-editor-break-standard-osx-shortcuts/30687>\
**Category:** UX\
**Tags:** keyboard-shortcuts\
**Created:** [2015 年7 月 1 日 20:14 UTC](https://meta.discourse.org/t/keyboard-shortcuts-in-editor-break-standard-osx-shortcuts/30687 "2015-07-01T20:14:46Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

作者： ![kportertx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kportertx/32/115310_2.png) [@kportertx](https://meta.discourse.org/u/kportertx)\
发布日期： [2019 年9 月 6 日 21:30 UTC](https://meta.discourse.org/t/keyboard-shortcuts-in-editor-break-standard-osx-shortcuts/30687/13 "2019-09-06T21:30:33Z")

</div>

其他受影响的用户：这是一个适用于 [Violent Monkey](https://violentmonkey.github.io/) 的脚本：

作为额外福利，它还修复了“查找”功能被许多网页覆盖的问题（这些网页最近将其改为站点搜索而非页面搜索，发布时与 Discourse 无关）。

```plaintext
// ==UserScript==
// @name 反键盘劫持
// @description 防止网页应用捕获并屏蔽重要的键盘快捷键
// @inject-into auto
// @version 1.1
// ==/UserScript==

function antigrab(e) {
  if (! e.ctrlKey) {
    return;
  }
 
  switch (e.keyCode) {
    case 65: // A - 跳转到行首
    case 69: // E - 跳转到行尾
    case 70: // F - 查找
    case 87: // W - 关闭窗口
    case 84: // T - 打开标签页
    case 75: // K - 删除到行尾
    case 89: // Y - 粘贴
      e.stopImmediatePropagation();
      e.stopPropagation();
  }
}

(function(){
unsafeWindow.document.addEventListener('keydown', antigrab, true);
})();

```

（灵感来源：[https://gist.github.com/rodneyrehm/5213304](https://gist.github.com/rodneyrehm/5213304)）

---

_[View the full topic](https://meta.discourse.org/t/keyboard-shortcuts-in-editor-break-standard-osx-shortcuts/30687)._
