Home > WP Plugin, WP Trick > WordPress 使用Ctrl+Enter快捷键发布评论

WordPress 使用Ctrl+Enter快捷键发布评论

June 7th, 2009 Huey, 1,031 Views Leave a comment Go to comments

使用键盘可以让你更简单地与计算机交互, 利用快捷键代替鼠操作,会更好的提高灌水效率! 哈 O(∩_∩)O…… 关于这个教程, 我在之前的 Huiの世界 已经发布过了, 当时的教程只介绍了一个方法, 今天在这里有两种方法供你参考, 针对新手和熟手, 总有一种适合你吧~ 当然效果是一样的! P.S.不知道什么时候开始习惯说废话了…

1. 通过插件实现
我想这个是大多数 WordPress 新手经常使用的方法, 虽然操作简单, 但是使用过多的插件会拖慢你博客载入速度, 速度第一啊, 我还是不推荐这个功能使用插件实现的.

WP-CommentsShortcut: Home | Download WP-CommentsShortcut | WP Version: 2.5 or higher

1. Unzip archive to the ‘/wp-content/plugins/’ directory
2. Activate the plugin through the ‘Plugins’ menu in WordPress
3. Make some changes in the ’setting’ => ‘WP Comments Shortcut’ to meet your preferences

2. 通过 JS 代码实现
为了这么个小功能, 使用插件的话, 的确有点夸张了, 而且只要一小段代码就可以实现. 来看下这段JS代码:

找到你当前使用的主题, 编辑 Comments.php, 搜索如下代码:

1
2
3
...
</form>
...

找到以后在这个前面加上

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<script type="text/javascript">       
        document.getElementById("comment").onkeydown = function (moz_ev)
        {
                var ev = null;
                if (window.event){
                        ev = window.event;
                }else{
                        ev = moz_ev;
                }
                if (ev != null && ev.ctrlKey && ev.keyCode == 13)
                {
                        document.getElementById("submit").click();
                }
        }
</script>

够简单吧, 也可以把以上代码保存为 JS 文件引用, 唯一缺陷就是 Submit 按钮上不会显示 (Ctrl+Enter) 类似的提示, 需要手动添加. :cool:

声明: 本站遵循 署名-非商业性使用-相同方式共享 3.0 共享协议. 转载请注明转自 玩软部落.
  1. June 10th, 2009 at 14:16 | #1

    这里用的就是这种方法么?

  2. June 11th, 2009 at 08:02 | #2

    @aunsen
    主题自带的功能,方法不一样,效果是一样的~

  1. No trackbacks yet.
How do I change my avatar? Go to gravatar.com and upload your preferred avatar. What is Gravatar?