我有几十年使用Emacs的经验,所以在Mac OS X上用于文本编辑的类似Emacs的键绑定非常好.不幸的是,一些网站(咳咳)选择用Javascript覆盖这些.例如,其中一个使controlB插入文本**强文本**,而不是返回一个字符.
有没有办法让Safari忽略试图重新映射标准OS X键绑定的Javascript键绑定?
解决方法:
这是Rob W’s script from meta,更新为仅阻止cntrl- *并修复,以便它与NinjaKit一起使用,NinjaKit是用于运行用户脚本的Safari扩展.
NinjaKit:
https://github.com/os0x/NinjaKit
脚本:
// ==UserScript==
// @name Cya WMD shortcuts
// @namespace Rob W
// @version 1.0
// @include http://apple.stackexchange.com/*
// @include https://*.com/*
// @include http://superuser.com/*
// @include http://meta.superuser.com/*
// @include http://serverfault.com/*
// @include http://meta.serverfault.com/*
// @include http://askubuntu.com/*
// @include http://meta.askubuntu.com/*
// @include http://*.stackexchange.com/*
// @include http://answers.onstartups.com/*
// @include http://meta.answers.onstartups.com/*
// @include http://stackapps.com/*
// @run-at document-end
// @grant none
// ==/UserScript==
(function () {
var p = document.getElementById('wmd-input');
console.log("wmd-input:" + p);
if (p) {
p = p.parentNode;
function ignore(e) {
if (e.ctrlKey) {
e.stopPropagation();
}
}
p.addEventListener('keydown', ignore, true);
p.addEventListener('keypress', ignore, true);
p.addEventListener('keyup', ignore, true);
}
})();