关于括号

时间:2015-07-09 17:39:47

标签: javascript adobe-brackets

我正在尝试在Adobe Brackets中找到Document对象的onChange方法,但我找不到它,我需要一个eventListener,每当我按下括号中的活动文档上的某个键时触发它。谁知道我怎么做?

1 个答案:

答案 0 :(得分:0)

查看Brackets API 编辑有一个keypress事件:
http://brackets.io/docs/current/modules/editor/Editor.html

您可以像这样使用它:

function keyHandler(BracketsEvent, Editor, KeyboardEvent) {
    return;
}

var EditorManager = brackets.getModule('editor/EditorManager');
EditorManager.on('activeEditorChange', function (e, editorGainingFocus, editorLosingFocus) {
    if (editorLosingFocus) {
        editorLosingFocus.off('keypress', keyHandler);
    }
    if (editorGainingFocus) {
        editorGainingFocus.on('keypress', keyHandler);
    }
});