【问题标题】:Is there an event for a keyboard initiated save in Ace Editor?Ace Editor 中是否存在键盘启动保存的事件?
【发布时间】:2015-10-26 09:15:05
【问题描述】:

在 Mac 和 Windows 中,当您按 COMMAND + S 或 CTRL + S 时,它通常用于保存文档。 Ace Editor 是否有我可以收听的跨平台事件?如果不是,我将如何捕获用户键盘启动的保存事件?

【问题讨论】:

    标签: ace-editor


    【解决方案1】:

    添加这样的命令

    editor.commands.addCommand({
        name: 'save',
        bindKey: {win: "Ctrl-S", "mac": "Cmd-S"},
        exec: function(editor) {
            console.log("saving", editor.session.getValue())
        }
    })
    

    【讨论】:

    • 我们也可以在 Linux 上使用它吗??如果是,那么我必须在bindKey: {win: "Ctrl-S", "mac": "Cmd-S"} 中添加什么??而且,感谢您为我们提供了一个很好的解决方案! :)
    • linux使用与windows相同的键绑定,没有办法只为linux指定不同的键绑定。
    • 所以你的意思是我必须在 Linux 操作系统上使用 'lin' ??
    • 好的!!非常感谢 !! ?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多